[Calc] Improve matrices support.

Fix bugs when matrices were saved.
Improve matrix support in parser.