Merge pull request #44 from somdoron/master

Few bug fixes
change the error handling to exceptions and error code.
add againException, TerminatingException and InvalidException