added write and inMemory for patterns, phrases