more debug logging; refactored potential match handling