Added environment stuff
JSON errors output debug bits when something goes wrong.