Replace fixed-size stack array with std::vector