Refactored query handlers and changed the shape of the output of service responses.