Fix bugs in the build system