fixed numerous bugs in matching code and starting writing test cases.  testing still not nearly complete