Upgraded logging a bit and query object. Middleware should be used instead