Use JSON response in more places and slightly impore error handling.