refine path handling, make it work on both unix and windows.