Use min instead of max

This was the problem causing a huge drop in performance. This is due to
the fact that each matrix block would calculate all the way to the end
of the block. In other words it would look like this for each block size
iteration:

 +------------------+                          +--------------------+
 |                  |                          |                    |
 |  +---------------+                          |  +------+          |
 |  |               | instead of looking like  |  | calc |          |
 |  |  calculated   |                          |  +------+          |
 |  |               |                          |                    |
 +--+---------------+                          +--------------------+