Make sure variables are initialized
findExtremes does not unconditionally set the variables, which may also be questionable. At least set them to 0 before, to make sure not to end up with complete garbage.