Completed impelementation of cachematrix