Fix hacks in splitMessage
Improve blank line insertion logic and add various comments