Clean up the rebuild script - this is ugly