Replaced appendSlash() by the more generic canonicalizeDir()
Replaced the call to appendSlash() to the more generic
canonicalizeDir().
Performed some cleanup.