fixed the extra flicker, added deletion of output dir