Refactor JSON management