Improved locking more and implemented directory_rename()