AGP-269: refactor context matcher