Fixed errors in Direction Index and Invert that were causing errors in pathfollowing and terrain generation