Some minor bugfixes in matching.