Cache generic modules and correctly record dependencies on them.
Materialize class implementation and mark classes complete so we can inherit
from them.
Merged.