Cleanup on some of the code to handle missing values and also setup a json response handler.