COMP: Fixed horrible memory leakage due to misunderstanding smart pointers