We could try encode some of the binary trees as linear arrays. This could lower both lookup time and memory consumption.