rename buildDir to tempDir, use trait for common file ops