fix some context bugs