Much better implementation of buildmode.  Other way was hacky and stupid
and complicated and I feel bad deleting it because it took so much
bugtesting.