Refactorizing & adding Json support