Fixed the biggest memory leak by using std::unique_ptr now