Fix issues with contexts and scoping (bug 926613)