Move cache to common assembly plus small refactoring.