Change from bool to int in the max/min index functions