Improved matrix iteration.