Moved the cache stuff out to a new abstract class.