Writing output json, cleaning up unnecessary libraries.