Add debug logging statements
Fix incorrect error messages, closing-paren indentation.