JSON objects get closed properly. Some sort of memory error going on now, needs valgrinding.