Refactor contexts