Fix warnings and use std::string::npos instead of -1