Rewriten recognizer - not quite drop in replacement

I'm just sending the PR to show you what i"ve been doing in case it is useful. It is completely up to you whether you take it, a subset of it or nothing.