finished clean up of cachematrix and added clear comments