Refactorized inefficient usage of std::string and const char[].