Major Overhaul of Pattern Match Checking (Fixes #595)