Problems with large JSON objects sent via stdio

Trying to fix it but the code is a mess and I don't know where the
problem lies exactly. It might have to do with JSON parsing. Often it
just hangs without an error. Think I'm gonna rewrite big parts of
generator.js, and think of a different system to pass the big JSON
objects, maybe streams or something.