Switch to rangebased for-loop...
... and use unique_ptr to ensure RAII idiom