added guards against zero length messages to string manipulator