fix race condition with changing directory
Merge pull request #364 from Fat-Zer/master

Fix race condition with changing directory