Add input matrix safety checks.