Logic changes to avoid a seg fault and actually run the row swapping code.