Context stack

Reimplementation of the context stack using a trait.