Got a basic version of dynamic maxDirectionChanges working