Some refactoring:

* Fixed a typo.
* 500 is returned only if the JSON is not parseable.
* All other errors are logged and then the input is returned.