Core/messages: Partially revert 1ae273e140e5f88325b4152859c5af09785fd687, which was causing errors on whitespace-only messages.

Signed-off-by: Martin Stone <martin@d7415.co.uk>
(cherry picked from commit ed24fc2eea769dfe16b8a97dc9a2b2fc91c405f8)
Core/connection: Better queue handling on quit.

Signed-off-by: Martin Stone <martin@d7415.co.uk>
(cherry picked from commit c46b3dbe239b8141855a94dddaaff956966794ec)