Refactoring and error handling
Merge pull request #13 from marek-ganko/error-handling

Refactoring and error handling