Fix a few bugs and a glaring build script bug.