Strange output, but why and how to solve it

You can save a lot of RAM by using the F() macro. Find all your string constants, and put them in an F() macro..

So instead of

    Serial.println(" recieved ok.");

you would use

    Serial.println( F(" recieved ok.") );