added (but not yet tested) pattern cacher