Many fixes and improvements in pmatch.  New tests.