tree_map now sorts by ID if squares are the same size
small bug fixes