Refactor contexts to the more accurate stacks