Refactored serialize string function to handle long and short strings.
Got query message to be sent correctly.