Generalized extendTo function.
Improved performance of getRow function.