fixed an occasionally occuring problem with file locking