move path functions in to separate file. Fix some headers