Some refactoring on path calculations, more to be done