Improved error handling

Improved error handling for a variety of cases, particularly bad method calls, and invalid package declarations.