Added contextual classes, and memoisation.