resolved memory usage - closing connections
path search more robust