Remove trailing slashes when normalizing the path.
Fix some regexp handling.