Changed treegen.js to gen.js, added more gen code