Refactor contexts to own class