Some memory optimization
Reduce memory usage during pattern recognition (uses a vector of
patterns instead of a map)