code to close json, code tweaks, few comments