Refactor matcher into separate lib and use forward decl where possible.