Initial support for error handling, close #23, #26