Working code for the new context mechanism.  Might have to rework the interface at some point.