Implemented caching for variables and methods