fixed bunch of memory leaks in json constructor