Improve handling of context-like objects in Leaf constructors