adding clean task and some minor optimizations