Remove unneeded functionality and tweak the generated output so we can #include it in C++ source code. This is a back-port of commit e159073d from the master branch.