Simplified error handling. Fixes #4