JSON fixes and more helpful error reporting