From Eldskegg: fixed changeDirection