applied Jenny Gray's suggested patches, mostly get_context_instance replacements

Signed-off-by: Joseph Rézeau <moodle@rezeau.org>