improve matches, fix bugs