Added support for scratch directories. Needs testing
Fix