1. mat %*% rank causes errors, I'll fix it next.