improved performance of the handlers and added JSON encoding. The server now sends back only the necessary data instead of the whole query result