added some debugging, and a test case for fixing matching issues