Refactored a bit to add miss caching and simpler extension building.
Not used.