1. fixed some major and stupid bugs in refinePath;