Fix some build logic and remove old build code