Clean up the way the stack message is modified

The previous method assumed that the stack messages were formatted a certain
way, while browsers may or may not conform to that way.