Do not raise an exception on shape mismatch.
Improved shape checking code.