Cleanup

@mikelehen some minor improvements to the code. I also changed the API to accept Map<String, Object> instead of JSONObject.