Fix some bugs in joining multiple paths.