Improved separation of html and json requests.