Refactored the error reporting. It's now centralized in a few static met...

...hod calls with null pointer checks.