General refactoring; added json methods