Fix a number of bugs and improve error handling
Bump version