Matrix: Added null checks