added JSON class and refactored everything for style/patterns