Very preliminary, kind of ugly matching system

Still don't have a generic algorithm, and there are lots of cases it
doesn't handle at all/well