Added caching, fixed regression