added JSON and some code cleanup