Move counting into the handler for more precise counts regardless of where an error might occur.
Ensure that the client data is cleaned up by moving the command execution to the deferred.