added json writing and started implementing svg optimization