Optimize the data structures to save memory