Fixing bug in hanging handlers. Only storing JSON if JSON is actually sent from the server