Added saving and deferred loading of dependent objects.
This is an initial sketch. Planning to cache reading dependent
objects so that the IN (...) queries are always optimal.