Windows: Fixed possible problems with file locks
OSX: Tweaked last fix