Refactor pypath implementation