improvements from cleanup.bat ported to bash