Flexibility and generalization in memory systems