Fix bugs introduced by merge conflicts

Plus updated gen-build.php to make sure that build/ files can still be built.