Bug fixes in --pattern-matching + increased error logging

@yilongli please review

A couple small bug fixes for pattern matching, plus I added some additional options to make it easier for non-K-developers to debug their definitions in the java backend.
please add some comments here, preferably with the rule which makes this method incorrect.