Adjusted the log statements to debug where appropriate.