refactor sanitizePath a bit more.