Improved error handling, all tests fixed.