Add support for sparse entries.

This also should also improve the memory efficiency, but I didn't bother getting numbers on that, I needed it for the functionality anyway, it's just a happy coincidence. :smiley: 
Done.