Move some build preview code to C