Fix smallinv for upper triangular matrices