Broke some of the chunks of the main state machine into their own methods for legibility.
To be fair, we ARE dealing with a state machine.
Merge branch 'master' into shutdown_with_known_bad_notification
Simplified and better encapsulated client state management.
Added more sensible shutdown states.
Renamed state-changing methods for clarity.
Improved rejected notification handling when shutting down.
Made shutdown tests actually test shutting down. They now fail.
Fixed a bug where a mis-ordered pipeline prevented malformed messages from being rejected.
Made the connection process more resume- and retry-friendly.
Added support for faster shutdowns if the thread has never actually attempted to send a notification.