Fixed bugs. Now caching works.