Normalized paths to remove multiple slashes

Commit 0b7eaf0 contains a refactoring to move up the checking of the input.