Fix matching failures. Also added some logging.