Fix path suffix logic and minor bugs.