Add debug message. Fix unclosed postgresql connection