updated c++ish memory management