Improvements in destination path creation

The code to determine the destination path from the source directory,
the contents of the directory and destination is now more robust and
should cover all cases.