Fixed a bug in the pivot finding method.