Improved error handling, json reporting