Fix some bugs. Improve error handling. More verbose output.