Use std::collections::{BTreeSet, BTreeMap} instead of std::collections::{TreeSet, TreeMap}.

Fixes #1076