Replace which invocations with actual path resolution code