Merge pull request #26 from sourishkrout/master

Basis for improved error handling.
Refactoring for more error handling.