Made better query logging.