Error Reporting Improved

Improved error reporting to help locate some bugs.