Solved the matrix caching problem.