Some refactoring of the matcher code.

Also start using the "final decision" function.