added option to preserve scratch dir