parsing json and misc bug fixes