Implemented caching

Used new R class system