Fix some bugs with matching entries