Replaced json.parse with parseJSON. Other small tweaks