Changed internal structures to extend TreeMap