Add clean task, fix script bugs