Code rearrangement and a terminal-notifier fix.

This was mostly to make terminal-notifier work with messages/nicks that began with opening braces of various kinds, which it doesn't like.