Improved handling of symlinks