Refactor service handler to allow wrapping everything
Protecting against an agent that disconnects too early