compressing json output and cleaning some code