Changed up a bunch of "new" calls to use the C++11 RAII idiom with std::unique_ptr.