Replaced manual allocation with std::vector