Switch to a more robust matrix rank function.