Fix the full path name issue and wrong casting issue