Removes code duplication in build-from-source