Update MAXDIM
More carray abstraction and refactoring