Encapsulate context implementation. The current implementantion based on lists may be a performance problem in the future, and we should be able to change it without affecting the whole code base.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>