added path caching and reduced path computations