Use scaffolds new module_build_dir function:

* Also cleaned up flag and prerule file checking.