Fixed minmax; Added tempate metaprogramming to eliminate code duplication; Fixed heuristic so the harmonic average is always greater or equal to 0.