Update cachematrix.R

Updated the code with more comments and minor modifications.