Added json saving and batch processing