When the first request comes in there is a potential race while the basedir is prepared (if another request comes in at that crucial time they collide). This change just synchronizes the method where the basedir is prepared (it's a once only operation). Fixes gh-187