Fix possible race-condition in using current folder