gen.sh: Code cleanup and finish comments