First version of nested type cache support

with unit tests