Reverted the separate caching and clean up as you go for speed.