Update cachematrix.R

Added explanatory comments and removed unnecessary code (refactored).