Prepare processFn to be generic
Ensure gracefully cleanup of tmp folder