Bug fixes regarding JSONObject creation