Doing some changes to the data structures to avoid wasting a lot of memory.