Changed map to vector of pairs for sorting purposes.

Also added depth parameter (z), but it appears that if everything is
scripted correctly it won't be that neccessary.