replaced treemap with btreemap and updated deprecated spawn