Fixed missing cleanup of tmp directories. Made the lock less unique to actually catch simultaneous operation.