The implementation of response handling could be refactored to be cleaner and to reduce heap allocations.