Replace pn_messenger_work based event handling with selectable based implementation in order to have more control. This greatly improves error handling and allows much cleaner tidying up of resources when errors occur