fixed some unhandled exceptions
Merge pull request #2 from adeven/error_handling

fixed some unhandled exceptions