Added handling for client disconnections and factored error handling into decorators.