Refactor the build system