Improved toJson util, changed architecture pattern