Fixed duplicate open in sh
Moved unsorted_map from the stack to the heap.