Small refactoring to JSON, protocol added