Rewrite build scripts and compilation