Improved passing of context to functions.