Directory fix

This is some changes to improve handling of directories. The primary one being renames of directories.