Refactoring towards json for communication over messages