splitting stuff from pattern.h into patternstore.h