Splitting relationship caches

The relationship caches for patterns matching data and patterns having
a class needed to be separated due to shared cache causing issues with
setting class counter on a pattern node.