Added comments, fixed log message, and changed query log messages to be DEBUG level