Clean and rewrite buildscript