Remove usages of using namespace std;

This is mandated by the google style guide:
https://google.github.io/styleguide/cppguide.html
diff --git a/src/command.cc b/src/command.cc
index da217bc..6bed3e1 100644
--- a/src/command.cc
+++ b/src/command.cc
@@ -41,8 +41,8 @@
     return "";
   }
 
-  virtual string DebugString() const override {
-    return string("AutoVar(") + sym_ + ")";
+  virtual std::string DebugString() const override {
+    return std::string("AutoVar(") + sym_ + ")";
   }
 
   virtual bool IsFunc(Evaluator*) const override { return true; }
@@ -60,7 +60,7 @@
    public:                                                            \
     name(CommandEvaluator* ce, const char* sym) : AutoVar(ce, sym) {} \
     virtual ~name() = default;                                        \
-    virtual void Eval(Evaluator* ev, string* s) const override;       \
+    virtual void Eval(Evaluator* ev, std::string* s) const override;  \
   }
 
 DECLARE_AUTO_VAR_CLASS(AutoAtVar);
@@ -76,7 +76,7 @@
   AutoSuffixDVar(CommandEvaluator* ce, const char* sym, Var* wrapped)
       : AutoVar(ce, sym), wrapped_(wrapped) {}
   virtual ~AutoSuffixDVar() = default;
-  virtual void Eval(Evaluator* ev, string* s) const override;
+  virtual void Eval(Evaluator* ev, std::string* s) const override;
 
  private:
   Var* wrapped_;
@@ -87,24 +87,24 @@
   AutoSuffixFVar(CommandEvaluator* ce, const char* sym, Var* wrapped)
       : AutoVar(ce, sym), wrapped_(wrapped) {}
   virtual ~AutoSuffixFVar() = default;
-  virtual void Eval(Evaluator* ev, string* s) const override;
+  virtual void Eval(Evaluator* ev, std::string* s) const override;
 
  private:
   Var* wrapped_;
 };
 
-void AutoAtVar::Eval(Evaluator*, string* s) const {
+void AutoAtVar::Eval(Evaluator*, std::string* s) const {
   *s += ce_->current_dep_node()->output.str();
 }
 
-void AutoLessVar::Eval(Evaluator*, string* s) const {
+void AutoLessVar::Eval(Evaluator*, std::string* s) const {
   auto& ai = ce_->current_dep_node()->actual_inputs;
   if (!ai.empty())
     *s += ai[0].str();
 }
 
-void AutoHatVar::Eval(Evaluator*, string* s) const {
-  unordered_set<StringPiece> seen;
+void AutoHatVar::Eval(Evaluator*, std::string* s) const {
+  std::unordered_set<StringPiece> seen;
   WordWriter ww(s);
   for (Symbol ai : ce_->current_dep_node()->actual_inputs) {
     if (seen.insert(ai.str()).second)
@@ -112,14 +112,14 @@
   }
 }
 
-void AutoPlusVar::Eval(Evaluator*, string* s) const {
+void AutoPlusVar::Eval(Evaluator*, std::string* s) const {
   WordWriter ww(s);
   for (Symbol ai : ce_->current_dep_node()->actual_inputs) {
     ww.Write(ai.str());
   }
 }
 
-void AutoStarVar::Eval(Evaluator*, string* s) const {
+void AutoStarVar::Eval(Evaluator*, std::string* s) const {
   const DepNode* n = ce_->current_dep_node();
   if (!n->output_pattern.IsValid())
     return;
@@ -127,15 +127,15 @@
   pat.Stem(n->output.str()).AppendToString(s);
 }
 
-void AutoQuestionVar::Eval(Evaluator* ev, string* s) const {
-  unordered_set<StringPiece> seen;
+void AutoQuestionVar::Eval(Evaluator* ev, std::string* s) const {
+  std::unordered_set<StringPiece> seen;
 
   if (ev->avoid_io()) {
     // Check timestamps using the shell at the start of rule execution
     // instead.
     *s += "${KATI_NEW_INPUTS}";
     if (!ce_->found_new_inputs()) {
-      string def;
+      std::string def;
 
       WordWriter ww(&def);
       ww.Write("KATI_NEW_INPUTS=$(find");
@@ -163,12 +163,12 @@
   }
 }
 
-void AutoNotImplementedVar::Eval(Evaluator* ev, string*) const {
+void AutoNotImplementedVar::Eval(Evaluator* ev, std::string*) const {
   ev->Error(StringPrintf("Automatic variable `$%s' isn't supported yet", sym_));
 }
 
-void AutoSuffixDVar::Eval(Evaluator* ev, string* s) const {
-  string buf;
+void AutoSuffixDVar::Eval(Evaluator* ev, std::string* s) const {
+  std::string buf;
   wrapped_->Eval(ev, &buf);
   WordWriter ww(s);
   for (StringPiece tok : WordScanner(buf)) {
@@ -176,8 +176,8 @@
   }
 }
 
-void AutoSuffixFVar::Eval(Evaluator* ev, string* s) const {
-  string buf;
+void AutoSuffixFVar::Eval(Evaluator* ev, std::string* s) const {
+  std::string buf;
   wrapped_->Eval(ev, &buf);
   WordWriter ww(s);
   for (StringPiece tok : WordScanner(buf)) {
@@ -232,7 +232,7 @@
   found_new_inputs_ = false;
   for (Value* v : n.cmds) {
     ev_->set_loc(v->Location());
-    const string&& cmds_buf = v->Eval(ev_);
+    const std::string&& cmds_buf = v->Eval(ev_);
     StringPiece cmds = cmds_buf;
     bool global_echo = !g_flags.is_silent_mode;
     bool global_ignore_error = false;
@@ -243,7 +243,7 @@
       size_t lf_cnt;
       size_t index = FindEndOfLine(cmds, 0, &lf_cnt);
       if (index == cmds.size())
-        index = string::npos;
+        index = std::string::npos;
       StringPiece cmd = TrimLeftSpace(cmds.substr(0, index));
       cmds = cmds.substr(index + 1);
 
@@ -257,7 +257,7 @@
         command.echo = echo;
         command.ignore_error = ignore_error;
       }
-      if (index == string::npos)
+      if (index == std::string::npos)
         break;
     }
     continue;
@@ -265,7 +265,7 @@
 
   if (!ev_->delayed_output_commands().empty()) {
     std::vector<Command> output_commands;
-    for (const string& cmd : ev_->delayed_output_commands()) {
+    for (const std::string& cmd : ev_->delayed_output_commands()) {
       Command& c = output_commands.emplace_back(n.output);
       c.cmd = cmd;
       c.echo = false;
diff --git a/src/command.h b/src/command.h
index fb1ade3..102c508 100644
--- a/src/command.h
+++ b/src/command.h
@@ -19,8 +19,6 @@
 
 #include "symtab.h"
 
-using namespace std;
-
 struct DepNode;
 class Evaluator;
 
@@ -28,7 +26,7 @@
   explicit Command(Symbol o)
       : output(o), echo(true), ignore_error(false), force_no_subshell(false) {}
   Symbol output;
-  string cmd;
+  std::string cmd;
   bool echo;
   bool ignore_error;
   bool force_no_subshell;
diff --git a/src/dep.cc b/src/dep.cc
index bf4c947..481711e 100644
--- a/src/dep.cc
+++ b/src/dep.cc
@@ -39,7 +39,7 @@
 static std::vector<std::unique_ptr<DepNode>> g_dep_node_pool;
 
 static Symbol ReplaceSuffix(Symbol s, Symbol newsuf) {
-  string r;
+  std::string r;
   AppendString(StripExt(s.str()), &r);
   r += '.';
   AppendString(newsuf.str(), &r);
@@ -48,8 +48,8 @@
 
 void ApplyOutputPattern(const Rule& r,
                         Symbol output,
-                        const vector<Symbol>& inputs,
-                        vector<Symbol>* out_inputs) {
+                        const std::vector<Symbol>& inputs,
+                        std::vector<Symbol>* out_inputs) {
   if (inputs.empty())
     return;
   if (r.is_suffix_rule) {
@@ -65,7 +65,7 @@
   CHECK(r.output_patterns.size() == 1);
   Pattern pat(r.output_patterns[0].str());
   for (Symbol input : inputs) {
-    string buf;
+    std::string buf;
     pat.AppendSubst(output.str(), input.str(), &buf);
     out_inputs->push_back(Intern(buf));
   }
@@ -98,7 +98,7 @@
     p.first->second->Add(name.substr(1), rule);
   }
 
-  void Get(StringPiece name, vector<const Rule*>* rules) const {
+  void Get(StringPiece name, std::vector<const Rule*>* rules) const {
     for (const Entry& ent : rules_) {
       if ((ent.suffix.empty() && name.empty()) ||
           HasSuffix(name, ent.suffix.substr(1))) {
@@ -121,8 +121,8 @@
   }
 
  private:
-  vector<Entry> rules_;
-  unordered_map<char, RuleTrie*> children_;
+  std::vector<Entry> rules_;
+  std::unordered_map<char, RuleTrie*> children_;
 };
 
 bool IsSuffixRule(Symbol output) {
@@ -132,18 +132,18 @@
   size_t dot_index = rest.find('.');
   // If there is only a single dot or the third dot, this is not a
   // suffix rule.
-  if (dot_index == string::npos ||
-      rest.substr(dot_index + 1).find('.') != string::npos) {
+  if (dot_index == std::string::npos ||
+      rest.substr(dot_index + 1).find('.') != std::string::npos) {
     return false;
   }
   return true;
 }
 
 struct RuleMerger {
-  vector<const Rule*> rules;
-  vector<pair<Symbol, RuleMerger*>> implicit_outputs;
-  vector<Symbol> symlink_outputs;
-  vector<Symbol> validations;
+  std::vector<const Rule*> rules;
+  std::vector<std::pair<Symbol, RuleMerger*>> implicit_outputs;
+  std::vector<Symbol> symlink_outputs;
+  std::vector<Symbol> validations;
   const Rule* primary_rule;
   const RuleMerger* parent;
   Symbol parent_sym;
@@ -153,7 +153,7 @@
       : primary_rule(nullptr), parent(nullptr), is_double_colon(false) {}
 
   void AddImplicitOutput(Symbol output, RuleMerger* merger) {
-    implicit_outputs.push_back(make_pair(output, merger));
+    implicit_outputs.push_back(std::make_pair(output, merger));
   }
 
   void AddSymlinkOutput(Symbol output) { symlink_outputs.push_back(output); }
@@ -292,8 +292,8 @@
 class DepBuilder {
  public:
   DepBuilder(Evaluator* ev,
-             const vector<const Rule*>& rules,
-             const unordered_map<Symbol, Vars*>& rule_vars)
+             const std::vector<const Rule*>& rules,
+             const std::unordered_map<Symbol, Vars*>& rule_vars)
       : ev_(ev),
         rule_vars_(rule_vars),
         implicit_rules_(new RuleTrie()),
@@ -315,7 +315,7 @@
 
   void HandleSpecialTargets() {
     Loc loc;
-    vector<Symbol> targets;
+    std::vector<Symbol> targets;
 
     if (GetRuleInputs(Intern(".PHONY"), &targets, &loc)) {
       for (Symbol t : targets)
@@ -355,7 +355,7 @@
 
   ~DepBuilder() {}
 
-  void Build(vector<Symbol> targets, vector<NamedDepNode>* nodes) {
+  void Build(std::vector<Symbol> targets, std::vector<NamedDepNode>* nodes) {
     if (!first_rule_.IsValid()) {
       ERROR("*** No targets.");
     }
@@ -402,7 +402,7 @@
            ::Exists(target.str());
   }
 
-  bool GetRuleInputs(Symbol s, vector<Symbol>* o, Loc* l) {
+  bool GetRuleInputs(Symbol s, std::vector<Symbol>* o, Loc* l) {
     auto found = rules_.find(s);
     if (found == rules_.end())
       return false;
@@ -417,7 +417,7 @@
     return true;
   }
 
-  void PopulateRules(const vector<const Rule*>& rules) {
+  void PopulateRules(const std::vector<const Rule*>& rules) {
     for (const Rule* rule : rules) {
       if (rule->outputs.empty()) {
         PopulateImplicitRule(rule);
@@ -435,7 +435,7 @@
       }
       auto var = vars->Lookup(implicit_outputs_var_name_);
       if (var->IsDefined()) {
-        string implicit_outputs;
+        std::string implicit_outputs;
         var->Eval(ev_, &implicit_outputs);
 
         for (StringPiece output : WordScanner(implicit_outputs)) {
@@ -447,7 +447,7 @@
 
       var = vars->Lookup(validations_var_name_);
       if (var->IsDefined()) {
-        string validations;
+        std::string validations;
         var->Eval(ev_, &validations);
 
         for (StringPiece validation : WordScanner(validations)) {
@@ -458,7 +458,7 @@
 
       var = vars->Lookup(symlink_outputs_var_name_);
       if (var->IsDefined()) {
-        string symlink_outputs;
+        std::string symlink_outputs;
         var->Eval(ev_, &symlink_outputs);
 
         for (StringPiece output : WordScanner(symlink_outputs)) {
@@ -485,7 +485,7 @@
 
     StringPiece input_suffix = rest.substr(0, dot_index);
     StringPiece output_suffix = rest.substr(dot_index + 1);
-    shared_ptr<Rule> r = make_shared<Rule>(*rule);
+    std::shared_ptr<Rule> r = std::make_shared<Rule>(*rule);
     r->inputs.clear();
     r->inputs.push_back(Intern(input_suffix));
     r->is_suffix_rule = true;
@@ -512,7 +512,7 @@
       return false;
     if (!rule->cmds.empty())
       return false;
-    const string& i = rule->inputs[0].str();
+    const std::string& i = rule->inputs[0].str();
     return (i == "RCS/%,v" || i == "RCS/%" || i == "%,v" || i == "s.%" ||
             i == "SCCS/s.%");
   }
@@ -551,14 +551,14 @@
   bool CanPickImplicitRule(const Rule* rule,
                            Symbol output,
                            DepNode* n,
-                           shared_ptr<Rule>* out_rule) {
+                           std::shared_ptr<Rule>* out_rule) {
     Symbol matched;
     for (Symbol output_pattern : rule->output_patterns) {
       Pattern pat(output_pattern.str());
       if (pat.Match(output.str())) {
         bool ok = true;
         for (Symbol input : rule->inputs) {
-          string buf;
+          std::string buf;
           pat.AppendSubst(output.str(), input.str(), &buf);
           if (!Exists(Intern(buf))) {
             ok = false;
@@ -575,14 +575,14 @@
     if (!matched.IsValid())
       return false;
 
-    *out_rule = make_shared<Rule>(*rule);
+    *out_rule = std::make_shared<Rule>(*rule);
     if ((*out_rule)->output_patterns.size() > 1) {
       // We should mark all other output patterns as used.
       Pattern pat(matched.str());
       for (Symbol output_pattern : rule->output_patterns) {
         if (output_pattern == matched)
           continue;
-        string buf;
+        std::string buf;
         pat.AppendSubst(output.str(), output_pattern.str(), &buf);
         done_[Intern(buf)] = n;
       }
@@ -610,7 +610,7 @@
   bool PickRule(Symbol output,
                 DepNode* n,
                 const RuleMerger** out_rule_merger,
-                shared_ptr<Rule>* pattern_rule,
+                std::shared_ptr<Rule>* pattern_rule,
                 Vars** out_var) {
     const RuleMerger* rule_merger = LookupRuleMerger(output);
     Vars* vars = LookupRuleVars(output);
@@ -624,7 +624,7 @@
       return true;
     }
 
-    vector<const Rule*> irules;
+    std::vector<const Rule*> irules;
     implicit_rules_->Get(output.str(), &irules);
     for (auto iter = irules.rbegin(); iter != irules.rend(); ++iter) {
       if (!CanPickImplicitRule(*iter, output, n, pattern_rule))
@@ -647,7 +647,7 @@
     if (found == suffix_rules_.end())
       return rule_merger != nullptr;
 
-    for (const shared_ptr<Rule>& irule : found->second) {
+    for (const std::shared_ptr<Rule>& irule : found->second) {
       CHECK(irule->inputs.size() == 1);
       Symbol input = ReplaceSuffix(output, irule->inputs[0]);
       if (!Exists(input))
@@ -683,7 +683,7 @@
     done_[output] = n;
 
     const RuleMerger* rule_merger = nullptr;
-    shared_ptr<Rule> pattern_rule;
+    std::shared_ptr<Rule> pattern_rule;
     Vars* vars;
     if (!PickRule(output, n, &rule_merger, &pattern_rule, &vars)) {
       return n;
@@ -702,7 +702,7 @@
     else
       RuleMerger().FillDepNode(output, pattern_rule.get(), n);
 
-    vector<unique_ptr<ScopedVar>> sv;
+    std::vector<std::unique_ptr<ScopedVar>> sv;
     ScopedFrame frame(ev_->Enter(FrameType::DEPENDENCY, output.str(), n->loc));
 
     if (vars) {
@@ -715,7 +715,7 @@
           Var* old_var = ev_->LookupVar(name);
           if (old_var->IsDefined()) {
             // TODO: This would be incorrect and has a leak.
-            shared_ptr<string> s = make_shared<string>();
+            std::shared_ptr<std::string> s = std::make_shared<std::string>();
             old_var->Eval(ev_, s.get());
             if (!s->empty())
               *s += ' ';
@@ -743,7 +743,7 @@
     }
 
     if (g_flags.warn_phony_looks_real && n->is_phony &&
-        output.str().find('/') != string::npos) {
+        output.str().find('/') != std::string::npos) {
       if (g_flags.werror_phony_looks_real) {
         ERROR_LOC(
             n->loc,
@@ -780,7 +780,7 @@
       done_[output] = n;
 
       if (g_flags.warn_phony_looks_real && n->is_phony &&
-          output.str().find('/') != string::npos) {
+          output.str().find('/') != std::string::npos) {
         if (g_flags.werror_phony_looks_real) {
           ERROR_LOC(n->loc,
                     "*** PHONY target \"%s\" looks like a real file (contains "
@@ -820,7 +820,7 @@
 
       bool is_phony = c->is_phony;
       if (!is_phony && !c->has_rule && g_flags.top_level_phony) {
-        is_phony = input.str().find('/') == string::npos;
+        is_phony = input.str().find('/') == std::string::npos;
       }
       if (!n->is_phony && is_phony) {
         if (g_flags.werror_real_to_phony) {
@@ -923,16 +923,17 @@
       return lhs.str() < rhs.str();
     }
   };
-  map<Symbol, RuleMerger, TargetComp> rules_;
-  const unordered_map<Symbol, Vars*>& rule_vars_;
-  unique_ptr<Vars> cur_rule_vars_;
+  std::map<Symbol, RuleMerger, TargetComp> rules_;
+  const std::unordered_map<Symbol, Vars*>& rule_vars_;
+  std::unique_ptr<Vars> cur_rule_vars_;
 
-  unique_ptr<RuleTrie> implicit_rules_;
-  typedef unordered_map<StringPiece, vector<shared_ptr<Rule>>> SuffixRuleMap;
+  std::unique_ptr<RuleTrie> implicit_rules_;
+  typedef std::unordered_map<StringPiece, std::vector<std::shared_ptr<Rule>>>
+      SuffixRuleMap;
   SuffixRuleMap suffix_rules_;
 
   Symbol first_rule_;
-  unordered_map<Symbol, DepNode*> done_;
+  std::unordered_map<Symbol, DepNode*> done_;
   SymbolSet phony_;
   SymbolSet restat_;
   Symbol depfile_var_name_;
@@ -943,10 +944,10 @@
 };
 
 void MakeDep(Evaluator* ev,
-             const vector<const Rule*>& rules,
-             const unordered_map<Symbol, Vars*>& rule_vars,
-             const vector<Symbol>& targets,
-             vector<NamedDepNode>* nodes) {
+             const std::vector<const Rule*>& rules,
+             const std::unordered_map<Symbol, Vars*>& rule_vars,
+             const std::vector<Symbol>& targets,
+             std::vector<NamedDepNode>* nodes) {
   DepBuilder db(ev, rules, rule_vars);
   ScopedTimeReporter tr("make dep (build)");
   db.Build(targets, nodes);
diff --git a/src/dep.h b/src/dep.h
index fc1d855..aff8d94 100644
--- a/src/dep.h
+++ b/src/dep.h
@@ -30,26 +30,26 @@
 class Vars;
 class Frame;
 
-typedef pair<Symbol, struct DepNode*> NamedDepNode;
+typedef std::pair<Symbol, struct DepNode*> NamedDepNode;
 
 struct DepNode {
   DepNode(Symbol output, bool is_phony, bool is_restat);
-  string DebugString();
+  std::string DebugString();
 
   Symbol output;
-  vector<Value*> cmds;
-  vector<NamedDepNode> deps;
-  vector<NamedDepNode> order_onlys;
-  vector<NamedDepNode> validations;
+  std::vector<Value*> cmds;
+  std::vector<NamedDepNode> deps;
+  std::vector<NamedDepNode> order_onlys;
+  std::vector<NamedDepNode> validations;
   bool has_rule;
   bool is_default_target;
   bool is_phony;
   bool is_restat;
-  vector<Symbol> implicit_outputs;
-  vector<Symbol> symlink_outputs;
-  vector<Symbol> actual_inputs;
-  vector<Symbol> actual_order_only_inputs;
-  vector<Symbol> actual_validations;
+  std::vector<Symbol> implicit_outputs;
+  std::vector<Symbol> symlink_outputs;
+  std::vector<Symbol> actual_inputs;
+  std::vector<Symbol> actual_order_only_inputs;
+  std::vector<Symbol> actual_validations;
   Vars* rule_vars;
   Var* depfile_var;
   Var* ninja_pool_var;
@@ -58,10 +58,10 @@
 };
 
 void MakeDep(Evaluator* ev,
-             const vector<const Rule*>& rules,
-             const unordered_map<Symbol, Vars*>& rule_vars,
-             const vector<Symbol>& targets,
-             vector<NamedDepNode>* nodes);
+             const std::vector<const Rule*>& rules,
+             const std::unordered_map<Symbol, Vars*>& rule_vars,
+             const std::vector<Symbol>& targets,
+             std::vector<NamedDepNode>* nodes);
 
 bool IsSpecialTarget(Symbol output);
 
diff --git a/src/eval.cc b/src/eval.cc
index 637f373..7dad261 100644
--- a/src/eval.cc
+++ b/src/eval.cc
@@ -315,7 +315,7 @@
     Error("*** empty variable name.");
 
   if (lhs == kKatiReadonlySym) {
-    string rhs;
+    std::string rhs;
     stmt->rhs->Eval(this, &rhs);
     for (auto const& name : WordScanner(rhs)) {
       Var* var = Intern(name).GetGlobalVar();
@@ -354,10 +354,10 @@
 // Returns the remainder of <before_term>.
 static StringPiece ParseRuleTargets(const Loc& loc,
                                     const StringPiece& before_term,
-                                    vector<Symbol>* targets,
+                                    std::vector<Symbol>* targets,
                                     bool* is_pattern_rule) {
   size_t pos = before_term.find(':');
-  if (pos == string::npos) {
+  if (pos == std::string::npos) {
     ERROR_LOC(loc, "*** missing separator.");
   }
   StringPiece targets_string = before_term.substr(0, pos);
@@ -378,7 +378,7 @@
 }
 
 // Strip leading spaces and trailing spaces and colons.
-static string FormatRuleError(const string& before_term) {
+static std::string FormatRuleError(const std::string& before_term) {
   if (before_term.size() == 0) {
     return before_term;
   }
@@ -396,7 +396,7 @@
 }
 
 void Evaluator::MarkVarsReadonly(Value* vars_list) {
-  string vars_list_string;
+  std::string vars_list_string;
   vars_list->Eval(this, &vars_list_string);
   for (auto const& name : WordScanner(vars_list_string)) {
     Var* var = current_scope_->Lookup(Intern(name));
@@ -407,7 +407,7 @@
   }
 }
 
-void Evaluator::EvalRuleSpecificAssign(const vector<Symbol>& targets,
+void Evaluator::EvalRuleSpecificAssign(const std::vector<Symbol>& targets,
                                        const RuleStmt* stmt,
                                        const StringPiece& after_targets,
                                        size_t separator_pos) {
@@ -463,15 +463,15 @@
   loc_ = stmt->loc();
   last_rule_ = NULL;
 
-  const string&& before_term = stmt->lhs->Eval(this);
+  const std::string&& before_term = stmt->lhs->Eval(this);
   // See semicolon.mk.
-  if (before_term.find_first_not_of(" \t\n;") == string::npos) {
+  if (before_term.find_first_not_of(" \t\n;") == std::string::npos) {
     if (stmt->sep == RuleStmt::SEP_SEMICOLON)
       Error("*** missing rule before commands.");
     return;
   }
 
-  vector<Symbol> targets;
+  std::vector<Symbol> targets;
   bool is_pattern_rule;
   StringPiece after_targets =
       ParseRuleTargets(loc_, before_term, &targets, &is_pattern_rule);
@@ -486,9 +486,9 @@
   // first assignment token.
   size_t separator_pos = after_targets.find_first_of("=;");
   char separator = '\0';
-  if (separator_pos != string::npos) {
+  if (separator_pos != std::string::npos) {
     separator = after_targets[separator_pos];
-  } else if (separator_pos == string::npos &&
+  } else if (separator_pos == std::string::npos &&
              (stmt->sep == RuleStmt::SEP_EQ ||
               stmt->sep == RuleStmt::SEP_FINALEQ)) {
     separator_pos = after_targets.size();
@@ -550,7 +550,7 @@
   loc_ = stmt->loc();
 
   if (!last_rule_) {
-    vector<Stmt*> stmts;
+    std::vector<Stmt*> stmts;
     ParseNotAfterRule(stmt->orig, stmt->loc(), &stmts);
     for (Stmt* a : stmts)
       a->Eval(this);
@@ -570,7 +570,7 @@
   switch (stmt->op) {
     case CondOp::IFDEF:
     case CondOp::IFNDEF: {
-      string var_name;
+      std::string var_name;
       stmt->lhs->Eval(this, &var_name);
       Symbol lhs = Intern(TrimRightSpace(var_name));
       if (const auto& s = lhs.str();
@@ -584,8 +584,8 @@
     }
     case CondOp::IFEQ:
     case CondOp::IFNEQ: {
-      const string&& lhs = stmt->lhs->Eval(this);
-      const string&& rhs = stmt->rhs->Eval(this);
+      const std::string&& lhs = stmt->lhs->Eval(this);
+      const std::string&& rhs = stmt->rhs->Eval(this);
       is_true = ((lhs == rhs) == (stmt->op == CondOp::IFEQ));
       break;
     }
@@ -594,7 +594,7 @@
       abort();
   }
 
-  const vector<Stmt*>* stmts;
+  const std::vector<Stmt*>* stmts;
   if (is_true) {
     stmts = &stmt->true_stmts;
   } else {
@@ -606,7 +606,7 @@
   }
 }
 
-void Evaluator::DoInclude(const string& fname) {
+void Evaluator::DoInclude(const std::string& fname) {
   CheckStack();
   COLLECT_STATS_WITH_SLOW_REPORT("included makefiles", fname.c_str());
 
@@ -633,7 +633,7 @@
   loc_ = stmt->loc();
   last_rule_ = NULL;
 
-  const string&& pats = stmt->expr->Eval(this);
+  const std::string&& pats = stmt->expr->Eval(this);
   for (StringPiece pat : WordScanner(pats)) {
     ScopedTerminator st(pat);
     const auto& files = Glob(pat.data());
@@ -647,7 +647,7 @@
 
     include_stack_.push_back(stmt->loc());
 
-    for (const string& fname : files) {
+    for (const std::string& fname : files) {
       if (!stmt->should_exist && g_flags.ignore_optional_include_pattern &&
           Pattern(g_flags.ignore_optional_include_pattern).Match(fname)) {
         continue;
@@ -666,11 +666,11 @@
   loc_ = stmt->loc();
   last_rule_ = NULL;
 
-  const string&& exports = stmt->expr->Eval(this);
+  const std::string&& exports = stmt->expr->Eval(this);
   for (StringPiece tok : WordScanner(exports)) {
     size_t equal_index = tok.find('=');
     StringPiece lhs;
-    if (equal_index == string::npos) {
+    if (equal_index == std::string::npos) {
       lhs = tok;
     } else if (equal_index == 0 ||
                (equal_index == 1 &&
@@ -842,12 +842,12 @@
   return result;
 }
 
-string Evaluator::EvalVar(Symbol name) {
+std::string Evaluator::EvalVar(Symbol name) {
   return LookupVar(name)->Eval(this);
 }
 
 ScopedFrame Evaluator::Enter(FrameType frame_type,
-                             const string& name,
+                             const std::string& name,
                              Loc loc) {
   if (!trace_) {
     return ScopedFrame(this, nullptr);
@@ -857,24 +857,24 @@
   return ScopedFrame(this, frame);
 }
 
-string Evaluator::GetShell() {
+std::string Evaluator::GetShell() {
   return EvalVar(kShellSym);
 }
 
-string Evaluator::GetShellFlag() {
+std::string Evaluator::GetShellFlag() {
   // TODO: Handle $(.SHELLFLAGS)
   return is_posix_ ? "-ec" : "-c";
 }
 
-string Evaluator::GetShellAndFlag() {
-  string shell = GetShell();
+std::string Evaluator::GetShellAndFlag() {
+  std::string shell = GetShell();
   shell += ' ';
   shell += GetShellFlag();
   return shell;
 }
 
 RulesAllowed Evaluator::GetAllowRules() {
-  string val = EvalVar(kAllowRulesSym);
+  std::string val = EvalVar(kAllowRulesSym);
   if (val == "warning") {
     return RULES_WARNING;
   } else if (val == "error") {
@@ -890,7 +890,7 @@
   }
 }
 
-void Evaluator::Error(const string& msg) {
+void Evaluator::Error(const std::string& msg) {
   PrintIncludeStack();
   ERROR_LOC(loc_, "%s", msg.c_str());
 }
@@ -901,7 +901,7 @@
            LOCF(lowest_loc_));
 }
 
-void Evaluator::DumpIncludeJSON(const string& filename) const {
+void Evaluator::DumpIncludeJSON(const std::string& filename) const {
   IncludeGraph graph;
   graph.MergeTreeNode(stack_.front());
   FILE* jsonfile;
diff --git a/src/eval.h b/src/eval.h
index fc7fcff..03370ec 100644
--- a/src/eval.h
+++ b/src/eval.h
@@ -27,8 +27,6 @@
 #include "string_piece.h"
 #include "symtab.h"
 
-using namespace std;
-
 class Makefile;
 class Rule;
 class Var;
@@ -59,7 +57,7 @@
 
   FrameType Type() const { return type_; }
   Frame* Parent() const { return parent_; }
-  const string& Name() const { return name_; }
+  const std::string& Name() const { return name_; }
   const Loc& Location() const { return location_; }
   const std::vector<std::unique_ptr<Frame>>& Children() const {
     return children_;
@@ -144,17 +142,19 @@
   // Equivalent to LookupVar, but doesn't mark as used.
   Var* PeekVar(Symbol name);
 
-  string EvalVar(Symbol name);
+  std::string EvalVar(Symbol name);
 
   const Loc& loc() const { return loc_; }
   void set_loc(const Loc& loc) { loc_ = loc; }
 
-  const vector<const Rule*>& rules() const { return rules_; }
-  const unordered_map<Symbol, Vars*>& rule_vars() const { return rule_vars_; }
-  const unordered_map<Symbol, bool>& exports() const { return exports_; }
+  const std::vector<const Rule*>& rules() const { return rules_; }
+  const std::unordered_map<Symbol, Vars*>& rule_vars() const {
+    return rule_vars_;
+  }
+  const std::unordered_map<Symbol, bool>& exports() const { return exports_; }
 
   void PrintIncludeStack();
-  void Error(const string& msg);
+  void Error(const std::string& msg);
 
   void in_bootstrap();
   void in_command_line();
@@ -165,10 +165,10 @@
   bool avoid_io() const { return avoid_io_; }
   void set_avoid_io(bool a) { avoid_io_ = a; }
 
-  const vector<string>& delayed_output_commands() const {
+  const std::vector<std::string>& delayed_output_commands() const {
     return delayed_output_commands_;
   }
-  void add_delayed_output_command(const string& c) {
+  void add_delayed_output_command(const std::string& c) {
     delayed_output_commands_.push_back(c);
   }
   void clear_delayed_output_commands() { delayed_output_commands_.clear(); }
@@ -179,14 +179,14 @@
   void IncrementEvalDepth() { eval_depth_++; }
   void DecrementEvalDepth() { eval_depth_--; }
 
-  ScopedFrame Enter(FrameType frame_type, const string& name, Loc loc);
+  ScopedFrame Enter(FrameType frame_type, const std::string& name, Loc loc);
   Frame* CurrentFrame() const {
     return stack_.empty() ? nullptr : stack_.back();
   };
 
-  string GetShell();
-  string GetShellFlag();
-  string GetShellAndFlag();
+  std::string GetShell();
+  std::string GetShellFlag();
+  std::string GetShellAndFlag();
 
   // Parse the current value of .KATI_ALLOW_RULES
   RulesAllowed GetAllowRules();
@@ -200,15 +200,15 @@
   }
 
   void DumpStackStats() const;
-  void DumpIncludeJSON(const string& filename) const;
+  void DumpIncludeJSON(const std::string& filename) const;
 
   bool ExportDeprecated() const { return export_message_ && !export_error_; };
   bool ExportObsolete() const { return export_error_; };
   void SetExportDeprecated(StringPiece msg) {
-    export_message_.reset(new string(msg.as_string()));
+    export_message_.reset(new std::string(msg.as_string()));
   }
   void SetExportObsolete(StringPiece msg) {
-    export_message_.reset(new string(msg.as_string()));
+    export_message_.reset(new std::string(msg.as_string()));
     export_error_ = true;
   }
 
@@ -226,7 +226,7 @@
                AssignOp op,
                bool is_override,
                bool* needs_assign);
-  void DoInclude(const string& fname);
+  void DoInclude(const std::string& fname);
 
   bool IsTraced(Symbol& name) const;
   void TraceVariableLookup(const char* operation, Symbol& name, Var* var);
@@ -238,14 +238,14 @@
 
   void MarkVarsReadonly(Value* var_list);
 
-  void EvalRuleSpecificAssign(const vector<Symbol>& targets,
+  void EvalRuleSpecificAssign(const std::vector<Symbol>& targets,
                               const RuleStmt* stmt,
                               const StringPiece& lhs_string,
                               size_t separator_pos);
 
-  unordered_map<Symbol, Vars*> rule_vars_;
-  vector<const Rule*> rules_;
-  unordered_map<Symbol, bool> exports_;
+  std::unordered_map<Symbol, Vars*> rule_vars_;
+  std::vector<const Rule*> rules_;
+  std::unordered_map<Symbol, bool> exports_;
   std::set<Symbol> symbols_for_eval_;
 
   Rule* last_rule_;
@@ -269,7 +269,7 @@
   int eval_depth_;
   // Commands which should run at ninja-time (i.e., info, warning, and
   // error).
-  vector<string> delayed_output_commands_;
+  std::vector<std::string> delayed_output_commands_;
 
   Symbol posix_sym_;
   bool is_posix_;
@@ -279,10 +279,10 @@
   void* lowest_stack_;
   Loc lowest_loc_;
 
-  unique_ptr<string> export_message_;
+  std::unique_ptr<std::string> export_message_;
   bool export_error_;
 
-  vector<string> profiled_files_;
+  std::vector<std::string> profiled_files_;
 
   static SymbolSet used_undefined_vars_;
 
diff --git a/src/exec.cc b/src/exec.cc
index 40f37dc..be82593 100644
--- a/src/exec.cc
+++ b/src/exec.cc
@@ -105,7 +105,7 @@
         fflush(stdout);
       }
       if (!g_flags.is_dry_run) {
-        string out;
+        std::string out;
         int result = RunCommand(shell_, shellflag_, command.cmd.c_str(),
                                 RedirectStderr::STDOUT, &out);
         printf("%s", out.c_str());
@@ -130,15 +130,15 @@
 
  private:
   CommandEvaluator ce_;
-  unordered_map<Symbol, double> done_;
-  string shell_;
-  string shellflag_;
+  std::unordered_map<Symbol, double> done_;
+  std::string shell_;
+  std::string shellflag_;
   uint64_t num_commands_;
 };
 
 }  // namespace
 
-void Exec(const vector<NamedDepNode>& roots, Evaluator* ev) {
+void Exec(const std::vector<NamedDepNode>& roots, Evaluator* ev) {
   Executor executor(ev);
   for (auto const& root : roots) {
     executor.ExecNode(*root.second, nullptr);
diff --git a/src/exec.h b/src/exec.h
index 34fda96..3b74ba4 100644
--- a/src/exec.h
+++ b/src/exec.h
@@ -17,10 +17,9 @@
 
 #include <vector>
 
-using namespace std;
 #include "dep.h"
 class Evaluator;
 
-void Exec(const vector<NamedDepNode>& roots, Evaluator* ev);
+void Exec(const std::vector<NamedDepNode>& roots, Evaluator* ev);
 
 #endif  // EXEC_H_
diff --git a/src/expr.cc b/src/expr.cc
index 40e7b7d..a3fdf62 100644
--- a/src/expr.cc
+++ b/src/expr.cc
@@ -29,8 +29,8 @@
 
 Evaluable::~Evaluable() {}
 
-string Evaluable::Eval(Evaluator* ev) const {
-  string s;
+std::string Evaluable::Eval(Evaluator* ev) const {
+  std::string s;
   Eval(ev, &s);
   return s;
 }
@@ -39,7 +39,7 @@
 
 Value::~Value() {}
 
-string Value::DebugString(const Value* v) {
+std::string Value::DebugString(const Value* v) {
   return v ? NoLineBreak(v->DebugString_()) : "(null)";
 }
 
@@ -51,7 +51,7 @@
 
   virtual bool IsFunc(Evaluator*) const override { return false; }
 
-  virtual void Eval(Evaluator* ev, string* s) const override {
+  virtual void Eval(Evaluator* ev, std::string* s) const override {
     ev->CheckStack();
     s->append(s_.begin(), s_.end());
   }
@@ -59,7 +59,7 @@
   virtual bool IsLiteral() const override { return true; }
   virtual StringPiece GetLiteralValueUnsafe() const override { return s_; }
 
-  virtual string DebugString_() const override { return s_.as_string(); }
+  virtual std::string DebugString_() const override { return s_.as_string(); }
 
  private:
   StringPiece s_;
@@ -82,7 +82,7 @@
     vals_.push_back(v2);
   }
 
-  ValueList(const Loc& loc, vector<Value*>* values) : ValueList(loc) {
+  ValueList(const Loc& loc, std::vector<Value*>* values) : ValueList(loc) {
     values->shrink_to_fit();
     values->swap(vals_);
   }
@@ -102,15 +102,15 @@
     return false;
   }
 
-  virtual void Eval(Evaluator* ev, string* s) const override {
+  virtual void Eval(Evaluator* ev, std::string* s) const override {
     ev->CheckStack();
     for (Value* v : vals_) {
       v->Eval(ev, s);
     }
   }
 
-  virtual string DebugString_() const override {
-    string r;
+  virtual std::string DebugString_() const override {
+    std::string r;
     for (Value* v : vals_) {
       if (r.empty()) {
         r += "ValueList(";
@@ -125,7 +125,7 @@
   }
 
  private:
-  vector<Value*> vals_;
+  std::vector<Value*> vals_;
 };
 
 class SymRef : public Value {
@@ -141,7 +141,7 @@
     return IsInteger(name_.str());
   }
 
-  virtual void Eval(Evaluator* ev, string* s) const override {
+  virtual void Eval(Evaluator* ev, std::string* s) const override {
     ev->CheckStack();
     Var* v = ev->LookupVarForEval(name_);
     v->Used(ev, name_);
@@ -149,7 +149,7 @@
     ev->VarEvalComplete(name_);
   }
 
-  virtual string DebugString_() const override {
+  virtual std::string DebugString_() const override {
     return StringPrintf("SymRef(%s)", name_.c_str());
   }
 
@@ -167,10 +167,10 @@
     return true;
   }
 
-  virtual void Eval(Evaluator* ev, string* s) const override {
+  virtual void Eval(Evaluator* ev, std::string* s) const override {
     ev->CheckStack();
     ev->IncrementEvalDepth();
-    const string&& name = name_->Eval(ev);
+    const std::string&& name = name_->Eval(ev);
     ev->DecrementEvalDepth();
     Symbol sym = Intern(name);
     Var* v = ev->LookupVarForEval(sym);
@@ -179,7 +179,7 @@
     ev->VarEvalComplete(sym);
   }
 
-  virtual string DebugString_() const override {
+  virtual std::string DebugString_() const override {
     return StringPrintf("VarRef(%s)", Value::DebugString(name_).c_str());
   }
 
@@ -201,17 +201,17 @@
     return name_->IsFunc(ev) || pat_->IsFunc(ev) || subst_->IsFunc(ev);
   }
 
-  virtual void Eval(Evaluator* ev, string* s) const override {
+  virtual void Eval(Evaluator* ev, std::string* s) const override {
     ev->CheckStack();
     ev->IncrementEvalDepth();
-    const string&& name = name_->Eval(ev);
+    const std::string&& name = name_->Eval(ev);
     Symbol sym = Intern(name);
     Var* v = ev->LookupVar(sym);
-    const string&& pat_str = pat_->Eval(ev);
-    const string&& subst = subst_->Eval(ev);
+    const std::string&& pat_str = pat_->Eval(ev);
+    const std::string&& subst = subst_->Eval(ev);
     ev->DecrementEvalDepth();
     v->Used(ev, sym);
-    const string&& value = v->Eval(ev);
+    const std::string&& value = v->Eval(ev);
     WordWriter ww(s);
     Pattern pat(pat_str);
     for (StringPiece tok : WordScanner(value)) {
@@ -220,7 +220,7 @@
     }
   }
 
-  virtual string DebugString_() const override {
+  virtual std::string DebugString_() const override {
     return StringPrintf("VarSubst(%s:%s=%s)", Value::DebugString(name_).c_str(),
                         Value::DebugString(pat_).c_str(),
                         Value::DebugString(subst_).c_str());
@@ -243,7 +243,7 @@
 
   virtual bool IsFunc(Evaluator*) const override { return true; }
 
-  virtual void Eval(Evaluator* ev, string* s) const override {
+  virtual void Eval(Evaluator* ev, std::string* s) const override {
     ScopedFrame frame(ev->Enter(FrameType::FUNCALL, fi_->name, Location()));
     ev->CheckStack();
     LOG("Invoke func %s(%s)", name(), JoinValues(args_, ",").c_str());
@@ -252,7 +252,7 @@
     ev->DecrementEvalDepth();
   }
 
-  virtual string DebugString_() const override {
+  virtual std::string DebugString_() const override {
     return StringPrintf("Func(%s %s)", fi_->name,
                         JoinValues(args_, ",").c_str());
   }
@@ -267,7 +267,7 @@
 
  private:
   const FuncInfo* fi_;
-  vector<Value*> args_;
+  std::vector<Value*> args_;
 };
 
 static char CloseParen(char c) {
@@ -311,7 +311,7 @@
   return new ValueList(loc, v1, v2, v3);
 }
 
-Value* Value::NewExpr(const Loc& loc, vector<Value*>* values) {
+Value* Value::NewExpr(const Loc& loc, std::vector<Value*>* values) {
   if (values->size() == 1) {
     Value* v = (*values)[0];
     values->clear();
@@ -427,7 +427,7 @@
         Symbol sym = Intern(lit->val());
         if (g_flags.enable_kati_warnings) {
           size_t found = sym.str().find_first_of(" ({");
-          if (found != string::npos) {
+          if (found != std::string::npos) {
             KATI_WARN_LOC(start_loc,
                           "*warning*: variable lookup with '%c': %.*s",
                           sym.str()[found], SPF(s));
@@ -489,7 +489,7 @@
     // GNU make accepts expressions like $((). See unmatched_paren*.mk
     // for detail.
     size_t found = s.find(cp);
-    if (found != string::npos) {
+    if (found != std::string::npos) {
       KATI_WARN_LOC(start_loc, "*warning*: unmatched parentheses: %.*s",
                     SPF(s));
       *index_out = s.size();
@@ -514,7 +514,7 @@
   char save_paren = 0;
   int paren_depth = 0;
   size_t i;
-  vector<Value*> list;
+  std::vector<Value*> list;
   for (i = 0; i < s.size(); i++) {
     Loc item_loc = *loc;
 
@@ -643,8 +643,8 @@
   return ParseExprImpl(loc, s, NULL, opt, &n);
 }
 
-string JoinValues(const vector<Value*>& vals, const char* sep) {
-  vector<string> val_strs;
+std::string JoinValues(const std::vector<Value*>& vals, const char* sep) {
+  std::vector<std::string> val_strs;
   val_strs.reserve(vals.size());
   for (Value* v : vals) {
     val_strs.push_back(Value::DebugString(v));
diff --git a/src/expr.h b/src/expr.h
index a731077..f64278d 100644
--- a/src/expr.h
+++ b/src/expr.h
@@ -21,14 +21,12 @@
 #include "loc.h"
 #include "string_piece.h"
 
-using namespace std;
-
 class Evaluator;
 
 class Evaluable {
  public:
-  virtual void Eval(Evaluator* ev, string* s) const = 0;
-  string Eval(Evaluator*) const;
+  virtual void Eval(Evaluator* ev, std::string* s) const = 0;
+  std::string Eval(Evaluator*) const;
   const Loc& Location() const { return loc_; }
   // Whether this Evaluable is either knowably a function (e.g. one of the
   // built-ins) or likely to be a function-type macro (i.e. one that has
@@ -55,7 +53,7 @@
   // All NewExpr calls take ownership of the Value instances.
   static Value* NewExpr(const Loc& loc, Value* v1, Value* v2);
   static Value* NewExpr(const Loc& loc, Value* v1, Value* v2, Value* v3);
-  static Value* NewExpr(const Loc& loc, vector<Value*>* values);
+  static Value* NewExpr(const Loc& loc, std::vector<Value*>* values);
 
   static Value* NewLiteral(StringPiece s);
   virtual ~Value();
@@ -63,11 +61,11 @@
   // Only safe after IsLiteral() returns true.
   virtual StringPiece GetLiteralValueUnsafe() const { return ""; }
 
-  static string DebugString(const Value*);
+  static std::string DebugString(const Value*);
 
  protected:
   Value(const Loc& loc);
-  virtual string DebugString_() const = 0;
+  virtual std::string DebugString_() const = 0;
 };
 
 enum struct ParseExprOpt {
@@ -87,6 +85,6 @@
                  StringPiece s,
                  ParseExprOpt opt = ParseExprOpt::NORMAL);
 
-string JoinValues(const vector<Value*>& vals, const char* sep);
+std::string JoinValues(const std::vector<Value*>& vals, const char* sep);
 
 #endif  // EXPR_H_
diff --git a/src/file.cc b/src/file.cc
index 9ef6708..43eacbc 100644
--- a/src/file.cc
+++ b/src/file.cc
@@ -26,7 +26,7 @@
 #include "parser.h"
 #include "stmt.h"
 
-Makefile::Makefile(const string& filename)
+Makefile::Makefile(const std::string& filename)
     : mtime_(0), filename_(filename), exists_(false) {
   int fd = open(filename.c_str(), O_RDONLY);
   if (fd < 0) {
diff --git a/src/file.h b/src/file.h
index 6af6696..757d7e7 100644
--- a/src/file.h
+++ b/src/file.h
@@ -20,28 +20,26 @@
 #include <string>
 #include <vector>
 
-using namespace std;
-
 struct Stmt;
 
 class Makefile {
  public:
-  explicit Makefile(const string& filename);
+  explicit Makefile(const std::string& filename);
   ~Makefile();
 
-  const string& buf() const { return buf_; }
-  const string& filename() const { return filename_; }
+  const std::string& buf() const { return buf_; }
+  const std::string& filename() const { return filename_; }
 
-  const vector<Stmt*>& stmts() const { return stmts_; }
-  vector<Stmt*>* mutable_stmts() { return &stmts_; }
+  const std::vector<Stmt*>& stmts() const { return stmts_; }
+  std::vector<Stmt*>* mutable_stmts() { return &stmts_; }
 
   bool Exists() const { return exists_; }
 
  private:
-  string buf_;
+  std::string buf_;
   uint64_t mtime_;
-  string filename_;
-  vector<Stmt*> stmts_;
+  std::string filename_;
+  std::vector<Stmt*> stmts_;
   bool exists_;
 };
 
diff --git a/src/file_cache.cc b/src/file_cache.cc
index eb64a42..d0b4ea5 100644
--- a/src/file_cache.cc
+++ b/src/file_cache.cc
@@ -14,11 +14,10 @@
 
 // +build ignore
 
-#include "file_cache.h"
-
 #include <unordered_map>
 
 #include "file.h"
+#include "file_cache.h"
 
 MakefileCacheManager::MakefileCacheManager() = default;
 
@@ -26,7 +25,7 @@
 
 class MakefileCacheManagerImpl : public MakefileCacheManager {
  public:
-  virtual const Makefile& ReadMakefile(const string& filename) override {
+  virtual const Makefile& ReadMakefile(const std::string& filename) override {
     auto iter = cache_.find(filename);
     if (iter != cache_.end()) {
       return iter->second;
@@ -34,13 +33,13 @@
     return (cache_.emplace(filename, filename).first)->second;
   }
 
-  virtual void GetAllFilenames(unordered_set<string>* out) override {
+  virtual void GetAllFilenames(std::unordered_set<std::string>* out) override {
     for (const auto& p : cache_)
       out->insert(p.first);
   }
 
  private:
-  unordered_map<string, Makefile> cache_;
+  std::unordered_map<std::string, Makefile> cache_;
 };
 
 MakefileCacheManager& MakefileCacheManager::Get() {
diff --git a/src/file_cache.h b/src/file_cache.h
index 2dca448..ce1cd9c 100644
--- a/src/file_cache.h
+++ b/src/file_cache.h
@@ -18,16 +18,14 @@
 #include <string>
 #include <unordered_set>
 
-using namespace std;
-
 class Makefile;
 
 class MakefileCacheManager {
  public:
   virtual ~MakefileCacheManager();
 
-  virtual const Makefile& ReadMakefile(const string& filename) = 0;
-  virtual void GetAllFilenames(unordered_set<string>* out) = 0;
+  virtual const Makefile& ReadMakefile(const std::string& filename) = 0;
+  virtual void GetAllFilenames(std::unordered_set<std::string>* out) = 0;
 
   static MakefileCacheManager& Get();
 
diff --git a/src/fileutil.cc b/src/fileutil.cc
index 14ee68a..f70d44a 100644
--- a/src/fileutil.cc
+++ b/src/fileutil.cc
@@ -63,15 +63,15 @@
   return GetTimestampFromStat(st);
 }
 
-int RunCommand(const string& shell,
-               const string& shellflag,
-               const string& cmd,
+int RunCommand(const std::string& shell,
+               const std::string& shellflag,
+               const std::string& cmd,
                RedirectStderr redirect_stderr,
-               string* s) {
+               std::string* s) {
   const char* argv[] = {NULL, NULL, NULL, NULL};
-  string cmd_with_shell;
-  if (shell[0] != '/' || shell.find_first_of(" $") != string::npos) {
-    string cmd_escaped = cmd;
+  std::string cmd_with_shell;
+  if (shell[0] != '/' || shell.find_first_of(" $") != std::string::npos) {
+    std::string cmd_escaped = cmd;
     EscapeShell(&cmd_escaped);
     cmd_with_shell = shell + " " + shellflag + " \"" + cmd_escaped + "\"";
     argv[0] = "/bin/sh";
diff --git a/src/fileutil.h b/src/fileutil.h
index 1ff4fc1..47751eb 100644
--- a/src/fileutil.h
+++ b/src/fileutil.h
@@ -24,8 +24,6 @@
 
 #include "string_piece.h"
 
-using namespace std;
-
 bool Exists(StringPiece f);
 double GetTimestampFromStat(const struct stat& st);
 double GetTimestamp(StringPiece f);
@@ -36,11 +34,11 @@
   DEV_NULL,
 };
 
-int RunCommand(const string& shell,
-               const string& shellflag,
-               const string& cmd,
+int RunCommand(const std::string& shell,
+               const std::string& shellflag,
+               const std::string& cmd,
                RedirectStderr redirect_stderr,
-               string* out);
+               std::string* out);
 
 std::string GetExecutablePath();
 
diff --git a/src/find.cc b/src/find.cc
index b693449..51a6276 100644
--- a/src/find.cc
+++ b/src/find.cc
@@ -50,7 +50,7 @@
 class FindCond {
  public:
   virtual ~FindCond() = default;
-  virtual bool IsTrue(const string& path, unsigned char type) const = 0;
+  virtual bool IsTrue(const std::string& path, unsigned char type) const = 0;
   virtual bool Countable() const = 0;
   virtual unsigned Count() const = 0;
 
@@ -62,24 +62,24 @@
 
 class NameCond : public FindCond {
  public:
-  explicit NameCond(const string& n) : name_(n) {
-    has_wildcard_ = (n.find_first_of("?*[") != string::npos);
+  explicit NameCond(const std::string& n) : name_(n) {
+    has_wildcard_ = (n.find_first_of("?*[") != std::string::npos);
   }
-  virtual bool IsTrue(const string& path, unsigned char) const override {
+  virtual bool IsTrue(const std::string& path, unsigned char) const override {
     return fnmatch(name_.c_str(), Basename(path).data(), 0) == 0;
   }
   virtual bool Countable() const override { return !has_wildcard_; }
   virtual unsigned Count() const override { return 1; }
 
  private:
-  string name_;
+  std::string name_;
   bool has_wildcard_;
 };
 
 class TypeCond : public FindCond {
  public:
   explicit TypeCond(unsigned char t) : type_(t) {}
-  virtual bool IsTrue(const string&, unsigned char type) const override {
+  virtual bool IsTrue(const std::string&, unsigned char type) const override {
     return type == type_;
   }
   virtual bool Countable() const override { return false; }
@@ -92,20 +92,22 @@
 class NotCond : public FindCond {
  public:
   NotCond(FindCond* c) : c_(c) {}
-  virtual bool IsTrue(const string& path, unsigned char type) const override {
+  virtual bool IsTrue(const std::string& path,
+                      unsigned char type) const override {
     return !c_->IsTrue(path, type);
   }
   virtual bool Countable() const override { return false; }
   virtual unsigned Count() const override { return 0; }
 
  private:
-  unique_ptr<FindCond> c_;
+  std::unique_ptr<FindCond> c_;
 };
 
 class AndCond : public FindCond {
  public:
   AndCond(FindCond* c1, FindCond* c2) : c1_(c1), c2_(c2) {}
-  virtual bool IsTrue(const string& path, unsigned char type) const override {
+  virtual bool IsTrue(const std::string& path,
+                      unsigned char type) const override {
     if (c1_->IsTrue(path, type))
       return c2_->IsTrue(path, type);
     return false;
@@ -114,13 +116,14 @@
   virtual unsigned Count() const override { return 0; }
 
  private:
-  unique_ptr<FindCond> c1_, c2_;
+  std::unique_ptr<FindCond> c1_, c2_;
 };
 
 class OrCond : public FindCond {
  public:
   OrCond(FindCond* c1, FindCond* c2) : c1_(c1), c2_(c2) {}
-  virtual bool IsTrue(const string& path, unsigned char type) const override {
+  virtual bool IsTrue(const std::string& path,
+                      unsigned char type) const override {
     if (!c1_->IsTrue(path, type))
       return c2_->IsTrue(path, type);
     return true;
@@ -134,7 +137,7 @@
   }
 
  private:
-  unique_ptr<FindCond> c1_, c2_;
+  std::unique_ptr<FindCond> c1_, c2_;
 };
 
 class DirentNode {
@@ -142,33 +145,35 @@
   virtual ~DirentNode() = default;
 
   virtual const DirentNode* FindDir(StringPiece) const { return NULL; }
-  virtual bool FindNodes(const FindCommand&,
-                         vector<pair<string, const DirentNode*>>&,
-                         string*,
-                         StringPiece) const {
+  virtual bool FindNodes(
+      const FindCommand&,
+      std::vector<std::pair<std::string, const DirentNode*>>&,
+      std::string*,
+      StringPiece) const {
     return true;
   }
-  virtual bool RunFind(const FindCommand& fc,
-                       const Loc& loc,
-                       int d,
-                       string* path,
-                       unordered_map<const DirentNode*, string>* cur_read_dirs,
-                       vector<string>& out) const = 0;
+  virtual bool RunFind(
+      const FindCommand& fc,
+      const Loc& loc,
+      int d,
+      std::string* path,
+      std::unordered_map<const DirentNode*, std::string>* cur_read_dirs,
+      std::vector<std::string>& out) const = 0;
 
   virtual bool IsDirectory() const = 0;
 
-  const string& base() const { return base_; }
+  const std::string& base() const { return base_; }
 
  protected:
-  explicit DirentNode(const string& name) {
+  explicit DirentNode(const std::string& name) {
     base_ = Basename(name).as_string();
   }
 
   void PrintIfNecessary(const FindCommand& fc,
-                        const string& path,
+                        const std::string& path,
                         unsigned char type,
                         int d,
-                        vector<string>& out) const {
+                        std::vector<std::string>& out) const {
     if (fc.print_cond && !fc.print_cond->IsTrue(path, type))
       return;
     if (d < fc.mindepth)
@@ -176,20 +181,20 @@
     out.push_back(path);
   }
 
-  string base_;
+  std::string base_;
 };
 
 class DirentFileNode : public DirentNode {
  public:
-  DirentFileNode(const string& name, unsigned char type)
+  DirentFileNode(const std::string& name, unsigned char type)
       : DirentNode(name), type_(type) {}
 
   virtual bool RunFind(const FindCommand& fc,
                        const Loc&,
                        int d,
-                       string* path,
-                       unordered_map<const DirentNode*, string>*,
-                       vector<string>& out) const override {
+                       std::string* path,
+                       std::unordered_map<const DirentNode*, std::string>*,
+                       std::vector<std::string>& out) const override {
     PrintIfNecessary(fc, *path, type_, d, out);
     return true;
   }
@@ -202,9 +207,10 @@
 
 struct ScopedReadDirTracker {
  public:
-  ScopedReadDirTracker(const DirentNode* n,
-                       const string& path,
-                       unordered_map<const DirentNode*, string>* cur_read_dirs)
+  ScopedReadDirTracker(
+      const DirentNode* n,
+      const std::string& path,
+      std::unordered_map<const DirentNode*, std::string>* cur_read_dirs)
       : n_(NULL), cur_read_dirs_(cur_read_dirs) {
     const auto& p = cur_read_dirs->emplace(n, path);
     if (p.second) {
@@ -220,17 +226,17 @@
   }
 
   bool ok() const { return conflicted_.empty(); }
-  const string& conflicted() const { return conflicted_; }
+  const std::string& conflicted() const { return conflicted_; }
 
  private:
-  string conflicted_;
+  std::string conflicted_;
   const DirentNode* n_;
-  unordered_map<const DirentNode*, string>* cur_read_dirs_;
+  std::unordered_map<const DirentNode*, std::string>* cur_read_dirs_;
 };
 
 class DirentDirNode : public DirentNode {
  public:
-  explicit DirentDirNode(const DirentDirNode* parent, const string& name)
+  explicit DirentDirNode(const DirentDirNode* parent, const std::string& name)
       : DirentNode(name), parent_(parent), name_(name) {}
 
   ~DirentDirNode() {
@@ -250,7 +256,7 @@
       return parent_;
 
     size_t index = d.find('/');
-    const string& p = d.substr(0, index).as_string();
+    const std::string& p = d.substr(0, index).as_string();
     if (p.empty() || p == ".")
       return FindDir(d.substr(index + 1));
     if (p == "..") {
@@ -261,7 +267,7 @@
 
     for (auto& child : children_) {
       if (p == child.first) {
-        if (index == string::npos)
+        if (index == std::string::npos)
           return child.second;
         StringPiece nd = d.substr(index + 1);
         return child.second->FindDir(nd);
@@ -270,10 +276,11 @@
     return NULL;
   }
 
-  virtual bool FindNodes(const FindCommand& fc,
-                         vector<pair<string, const DirentNode*>>& results,
-                         string* path,
-                         StringPiece d) const override {
+  virtual bool FindNodes(
+      const FindCommand& fc,
+      std::vector<std::pair<std::string, const DirentNode*>>& results,
+      std::string* path,
+      StringPiece d) const override {
     if (!is_initialized_) {
       initialize();
     }
@@ -284,11 +291,11 @@
     size_t orig_path_size = path->size();
 
     size_t index = d.find('/');
-    const string& p = d.substr(0, index).as_string();
+    const std::string& p = d.substr(0, index).as_string();
 
     if (p.empty() || p == ".") {
       path->append(p);
-      if (index == string::npos) {
+      if (index == std::string::npos) {
         results.emplace_back(*path, this);
         return true;
       }
@@ -301,14 +308,14 @@
         return false;
       }
       path->append(p);
-      if (index == string::npos) {
+      if (index == std::string::npos) {
         results.emplace_back(*path, parent_);
         return true;
       }
       return parent_->FindNodes(fc, results, path, d.substr(index + 1));
     }
 
-    bool is_wild = p.find_first_of("?*[") != string::npos;
+    bool is_wild = p.find_first_of("?*[") != std::string::npos;
     if (is_wild) {
       fc.read_dirs->insert(*path);
     }
@@ -322,7 +329,7 @@
       }
       if (matches) {
         path->append(child.first);
-        if (index == string::npos) {
+        if (index == std::string::npos) {
           results.emplace_back(*path, child.second);
         } else {
           if (!child.second->FindNodes(fc, results, path,
@@ -337,12 +344,13 @@
     return true;
   }
 
-  virtual bool RunFind(const FindCommand& fc,
-                       const Loc& loc,
-                       int d,
-                       string* path,
-                       unordered_map<const DirentNode*, string>* cur_read_dirs,
-                       vector<string>& out) const override {
+  virtual bool RunFind(
+      const FindCommand& fc,
+      const Loc& loc,
+      int d,
+      std::string* path,
+      std::unordered_map<const DirentNode*, std::string>* cur_read_dirs,
+      std::vector<std::string>& out) const override {
     if (!is_initialized_) {
       initialize();
     }
@@ -450,7 +458,7 @@
     }
   }
 
-  static unsigned char GetDtType(const string& path) {
+  static unsigned char GetDtType(const std::string& path) {
     struct stat st;
     if (lstat(path.c_str(), &st)) {
       PERROR("stat for %s", path.c_str());
@@ -462,14 +470,15 @@
 
   const DirentDirNode* parent_;
 
-  mutable vector<pair<string, DirentNode*>> children_;
-  mutable string name_;
+  mutable std::vector<std::pair<std::string, DirentNode*>> children_;
+  mutable std::string name_;
   mutable bool is_initialized_ = false;
 };
 
 class DirentSymlinkNode : public DirentNode {
  public:
-  explicit DirentSymlinkNode(const DirentDirNode* parent, const string& name)
+  explicit DirentSymlinkNode(const DirentDirNode* parent,
+                             const std::string& name)
       : DirentNode(name), name_(name), parent_(parent) {}
 
   virtual const DirentNode* FindDir(StringPiece d) const override {
@@ -481,10 +490,11 @@
     return NULL;
   }
 
-  virtual bool FindNodes(const FindCommand& fc,
-                         vector<pair<string, const DirentNode*>>& results,
-                         string* path,
-                         StringPiece d) const override {
+  virtual bool FindNodes(
+      const FindCommand& fc,
+      std::vector<std::pair<std::string, const DirentNode*>>& results,
+      std::string* path,
+      StringPiece d) const override {
     if (!is_initialized_) {
       initialize();
     }
@@ -500,12 +510,13 @@
     return to_->FindNodes(fc, results, path, d);
   }
 
-  virtual bool RunFind(const FindCommand& fc,
-                       const Loc& loc,
-                       int d,
-                       string* path,
-                       unordered_map<const DirentNode*, string>* cur_read_dirs,
-                       vector<string>& out) const override {
+  virtual bool RunFind(
+      const FindCommand& fc,
+      const Loc& loc,
+      int d,
+      std::string* path,
+      std::unordered_map<const DirentNode*, std::string>* cur_read_dirs,
+      std::vector<std::string>& out) const override {
     unsigned char type = DT_LNK;
     if (fc.follows_symlinks && !is_initialized_) {
       initialize();
@@ -570,7 +581,7 @@
     is_initialized_ = true;
   }
 
-  mutable string name_;
+  mutable std::string name_;
   const DirentDirNode* parent_;
 
   mutable const DirentNode* to_ = nullptr;
@@ -598,7 +609,7 @@
         !strcmp(ent->d_name, ".repo") || !strcmp(ent->d_name, ".git"))
       continue;
 
-    string npath = name_;
+    std::string npath = name_;
     if (!name_.empty())
       npath += '/';
     npath += ent->d_name;
@@ -686,7 +697,7 @@
       }
       // But if there are any others, we can't support it, as unescaping would
       // require allocation
-      if (tok->find("\\") != string::npos) {
+      if (tok->find("\\") != std::string::npos) {
         return false;
       }
     }
@@ -716,14 +727,14 @@
     if (tok == "-not" || tok == "!") {
       if (!GetNextToken(&tok) || tok.empty())
         return NULL;
-      unique_ptr<FindCond> c(ParseFact(tok));
+      std::unique_ptr<FindCond> c(ParseFact(tok));
       if (!c.get())
         return NULL;
       return new NotCond(c.release());
     } else if (tok == "(") {
       if (!GetNextToken(&tok) || tok.empty())
         return NULL;
-      unique_ptr<FindCond> c(ParseExpr(tok));
+      std::unique_ptr<FindCond> c(ParseExpr(tok));
       if (!GetNextToken(&tok) || tok != ")") {
         return NULL;
       }
@@ -760,7 +771,7 @@
   }
 
   FindCond* ParseTerm(StringPiece tok) {
-    unique_ptr<FindCond> c(ParseFact(tok));
+    std::unique_ptr<FindCond> c(ParseFact(tok));
     if (!c.get())
       return NULL;
     while (true) {
@@ -776,7 +787,7 @@
           return c.release();
         }
       }
-      unique_ptr<FindCond> r(ParseFact(tok));
+      std::unique_ptr<FindCond> r(ParseFact(tok));
       if (!r.get()) {
         return NULL;
       }
@@ -785,7 +796,7 @@
   }
 
   FindCond* ParseExpr(StringPiece tok) {
-    unique_ptr<FindCond> c(ParseTerm(tok));
+    std::unique_ptr<FindCond> c(ParseTerm(tok));
     if (!c.get())
       return NULL;
     while (true) {
@@ -797,7 +808,7 @@
       }
       if (!GetNextToken(&tok) || tok.empty())
         return NULL;
-      unique_ptr<FindCond> r(ParseTerm(tok));
+      std::unique_ptr<FindCond> r(ParseTerm(tok));
       if (!r.get()) {
         return NULL;
       }
@@ -841,7 +852,7 @@
       } else if (tok == "-maxdepth") {
         if (!GetNextToken(&tok) || tok.empty())
           return false;
-        const string& depth_str = tok.as_string();
+        const std::string& depth_str = tok.as_string();
         char* endptr;
         long d = strtol(depth_str.c_str(), &endptr, 10);
         if (endptr != depth_str.data() + depth_str.size() || d < 0 ||
@@ -861,7 +872,7 @@
           return false;
         }
         fc_->redirect_to_devnull = true;
-      } else if (tok.find_first_of("|;&><'\"") != string::npos) {
+      } else if (tok.find_first_of("|;&><'\"") != std::string::npos) {
         return false;
       } else {
         fc_->finddirs.push_back(tok.as_string());
@@ -873,7 +884,7 @@
     fc_->type = FindCommandType::FINDLEAVES;
     fc_->follows_symlinks = true;
     StringPiece tok;
-    vector<string> findfiles;
+    std::vector<std::string> findfiles;
     while (true) {
       if (!GetNextToken(&tok))
         return false;
@@ -909,7 +920,8 @@
         CHECK(!fc_->prune_cond.get());
         fc_->prune_cond.reset(cond);
       } else if (HasPrefix(tok, "--mindepth=")) {
-        string mindepth_str = tok.substr(strlen("--mindepth=")).as_string();
+        std::string mindepth_str =
+            tok.substr(strlen("--mindepth=")).as_string();
         char* endptr;
         long d = strtol(mindepth_str.c_str(), &endptr, 10);
         if (endptr != mindepth_str.data() + mindepth_str.size() ||
@@ -945,7 +957,7 @@
       if (tok == "cd") {
         if (!GetNextToken(&tok) || tok.empty() || !fc_->chdir.empty())
           return false;
-        if (tok.find_first_of("?*[") != string::npos)
+        if (tok.find_first_of("?*[") != std::string::npos)
           return false;
         fc_->chdir = tok.as_string();
         if (!GetNextToken(&tok) || (tok != ";" && tok != "&&"))
@@ -1018,10 +1030,10 @@
     return r;
   }
 
-  virtual bool HandleFind(const string& cmd UNUSED,
+  virtual bool HandleFind(const std::string& cmd UNUSED,
                           const FindCommand& fc,
                           const Loc& loc,
-                          string* out) override {
+                          std::string* out) override {
     if (!CanHandle(fc.chdir)) {
       LOG("FindEmulator: Cannot handle chdir (%.*s): %s", SPF(fc.chdir),
           cmd.c_str());
@@ -1063,17 +1075,17 @@
       }
     }
 
-    vector<string> results;
-    for (const string& finddir : fc.finddirs) {
-      string fullpath = ConcatDir(fc.chdir, finddir);
+    std::vector<std::string> results;
+    for (const std::string& finddir : fc.finddirs) {
+      std::string fullpath = ConcatDir(fc.chdir, finddir);
       if (!CanHandle(fullpath)) {
         LOG("FindEmulator: Cannot handle find dir (%s): %s", fullpath.c_str(),
             cmd.c_str());
         return false;
       }
 
-      string findnodestr;
-      vector<pair<string, const DirentNode*>> bases;
+      std::string findnodestr;
+      std::vector<std::pair<std::string, const DirentNode*>> bases;
       if (!root->FindNodes(fc, bases, &findnodestr, finddir)) {
         return false;
       }
@@ -1093,7 +1105,7 @@
       sort(bases.begin(), bases.end());
 
       for (auto [path, base] : bases) {
-        unordered_map<const DirentNode*, string> cur_read_dirs;
+        std::unordered_map<const DirentNode*, std::string> cur_read_dirs;
         if (!base->RunFind(fc, loc, 0, &path, &cur_read_dirs, results)) {
           LOG("FindEmulator: RunFind failed: %s", cmd.c_str());
           return false;
@@ -1104,7 +1116,7 @@
     if (results.size() > 0) {
       // Calculate and reserve necessary space in out
       size_t new_length = 0;
-      for (const string& result : results) {
+      for (const std::string& result : results) {
         new_length += result.size() + 1;
       }
       out->reserve(out->size() + new_length - 1);
@@ -1114,7 +1126,7 @@
       }
 
       WordWriter writer(out);
-      for (const string& result : results) {
+      for (const std::string& result : results) {
         writer.Write(result);
       }
     }
@@ -1134,12 +1146,12 @@
       depth(INT_MAX),
       mindepth(INT_MIN),
       redirect_to_devnull(false),
-      found_files(new vector<string>()),
-      read_dirs(new unordered_set<string>()) {}
+      found_files(new std::vector<std::string>()),
+      read_dirs(new std::unordered_set<std::string>()) {}
 
 FindCommand::~FindCommand() {}
 
-bool FindCommand::Parse(const string& cmd) {
+bool FindCommand::Parse(const std::string& cmd) {
   FindCommandParser fcp(cmd, this);
   if (!HasWord(cmd, "find") && !HasWord(cmd, "build/tools/findleaves.py") &&
       !HasWord(cmd, "build/make/tools/findleaves.py"))
diff --git a/src/find.h b/src/find.h
index 2a1abe4..24407e9 100644
--- a/src/find.h
+++ b/src/find.h
@@ -23,8 +23,6 @@
 #include "loc.h"
 #include "string_piece.h"
 
-using namespace std;
-
 class FindCond;
 
 enum struct FindCommandType {
@@ -37,21 +35,21 @@
   FindCommand();
   ~FindCommand();
 
-  bool Parse(const string& cmd);
+  bool Parse(const std::string& cmd);
 
   FindCommandType type;
-  string chdir;
-  string testdir;
-  vector<string> finddirs;
+  std::string chdir;
+  std::string testdir;
+  std::vector<std::string> finddirs;
   bool follows_symlinks;
-  unique_ptr<FindCond> print_cond;
-  unique_ptr<FindCond> prune_cond;
+  std::unique_ptr<FindCond> print_cond;
+  std::unique_ptr<FindCond> prune_cond;
   int depth;
   int mindepth;
   bool redirect_to_devnull;
 
-  unique_ptr<vector<string>> found_files;
-  unique_ptr<unordered_set<string>> read_dirs;
+  std::unique_ptr<std::vector<std::string>> found_files;
+  std::unique_ptr<std::unordered_set<std::string>> read_dirs;
 
  private:
   FindCommand(const FindCommand&) = delete;
@@ -62,10 +60,10 @@
  public:
   virtual ~FindEmulator() = default;
 
-  virtual bool HandleFind(const string& cmd,
+  virtual bool HandleFind(const std::string& cmd,
                           const FindCommand& fc,
                           const Loc& loc,
-                          string* out) = 0;
+                          std::string* out) = 0;
 
   static FindEmulator* Get();
   static unsigned int GetNodeCount();
diff --git a/src/find_test.cc b/src/find_test.cc
index e8d521c..b8502f9 100644
--- a/src/find_test.cc
+++ b/src/find_test.cc
@@ -32,7 +32,7 @@
   }
 
   InitFindEmulator();
-  string cmd;
+  std::string cmd;
   for (int i = 1; i < argc; i++) {
     if (i > 1)
       cmd += ' ';
@@ -43,7 +43,7 @@
     fprintf(stderr, "Find emulator does not support this command\n");
     return 1;
   }
-  string out;
+  std::string out;
   if (!FindEmulator::Get()->HandleFind(cmd, fc, Loc(), &out)) {
     fprintf(stderr, "Find emulator does not support this command\n");
     return 1;
@@ -54,8 +54,8 @@
   }
 }
 
-string Run(const string& cmd) {
-  string s;
+std::string Run(const std::string& cmd) {
+  std::string s;
   int ret = RunCommand("/bin/sh", "-c", cmd, RedirectStderr::NONE, &s);
 
   if (ret != 0) {
@@ -68,22 +68,22 @@
 
 static bool unit_test_failed = false;
 
-void CompareFind(const string& cmd) {
-  string native = Run(cmd);
+void CompareFind(const std::string& cmd) {
+  std::string native = Run(cmd);
 
   FindCommand fc;
   if (!fc.Parse(cmd)) {
     fprintf(stderr, "Find emulator cannot parse `%s`\n", cmd.c_str());
     exit(1);
   }
-  string emulated;
+  std::string emulated;
   if (!FindEmulator::Get()->HandleFind(cmd, fc, Loc(), &emulated)) {
     fprintf(stderr, "Find emulator cannot handle `%s`\n", cmd.c_str());
     exit(1);
   }
 
-  vector<StringPiece> nativeWords;
-  vector<StringPiece> emulatedWords;
+  std::vector<StringPiece> nativeWords;
+  std::vector<StringPiece> emulatedWords;
 
   WordScanner(native).Split(&nativeWords);
   WordScanner(emulated).Split(&emulatedWords);
@@ -109,7 +109,7 @@
   }
 }
 
-void ExpectParseFailure(const string& cmd) {
+void ExpectParseFailure(const std::string& cmd) {
   FindCommand fc;
   if (fc.Parse(cmd)) {
     fprintf(stderr, "Expected parse failure for `%s`\n", cmd.c_str());
diff --git a/src/flags.cc b/src/flags.cc
index 1bba336..ea2a663 100644
--- a/src/flags.cc
+++ b/src/flags.cc
@@ -57,7 +57,7 @@
 
   if (const char* makeflags = getenv("MAKEFLAGS")) {
     for (StringPiece tok : WordScanner(makeflags)) {
-      if (!HasPrefix(tok, "-") && tok.find('=') != string::npos)
+      if (!HasPrefix(tok, "-") && tok.find('=') != std::string::npos)
         cl_vars.push_back(tok);
     }
   }
diff --git a/src/flags.h b/src/flags.h
index e173730..83bbe78 100644
--- a/src/flags.h
+++ b/src/flags.h
@@ -22,8 +22,6 @@
 #include "strutil.h"
 #include "symtab.h"
 
-using namespace std;
-
 struct Flags {
   bool detect_android_echo;
   bool detect_depfiles;
@@ -77,11 +75,11 @@
   int num_cpus;
   int num_jobs;
   int remote_num_jobs;
-  vector<const char*> subkati_args;
-  vector<Symbol> targets;
-  vector<StringPiece> cl_vars;
-  vector<string> writable;
-  vector<Pattern> traced_variables_pattern;
+  std::vector<const char*> subkati_args;
+  std::vector<Symbol> targets;
+  std::vector<StringPiece> cl_vars;
+  std::vector<std::string> writable;
+  std::vector<Pattern> traced_variables_pattern;
 
   void Parse(int argc, char** argv);
 };
diff --git a/src/func.cc b/src/func.cc
index 89f9e16..1171deb 100644
--- a/src/func.cc
+++ b/src/func.cc
@@ -45,11 +45,11 @@
 
 // TODO: This code is very similar to
 // NinjaGenerator::TranslateCommand. Factor them out.
-void StripShellComment(string* cmd) {
-  if (cmd->find('#') == string::npos)
+void StripShellComment(std::string* cmd) {
+  if (cmd->find('#') == std::string::npos)
     return;
 
-  string res;
+  std::string res;
   bool prev_backslash = false;
   // Set space as an initial value so the leading comment will be
   // stripped out.
@@ -98,10 +98,12 @@
   cmd->swap(res);
 }
 
-void PatsubstFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& pat_str = args[0]->Eval(ev);
-  const string&& repl = args[1]->Eval(ev);
-  const string&& str = args[2]->Eval(ev);
+void PatsubstFunc(const std::vector<Value*>& args,
+                  Evaluator* ev,
+                  std::string* s) {
+  const std::string&& pat_str = args[0]->Eval(ev);
+  const std::string&& repl = args[1]->Eval(ev);
+  const std::string&& str = args[2]->Eval(ev);
   WordWriter ww(s);
   Pattern pat(pat_str);
   for (StringPiece tok : WordScanner(str)) {
@@ -110,18 +112,18 @@
   }
 }
 
-void StripFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& str = args[0]->Eval(ev);
+void StripFunc(const std::vector<Value*>& args, Evaluator* ev, std::string* s) {
+  const std::string&& str = args[0]->Eval(ev);
   WordWriter ww(s);
   for (StringPiece tok : WordScanner(str)) {
     ww.Write(tok);
   }
 }
 
-void SubstFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& pat = args[0]->Eval(ev);
-  const string&& repl = args[1]->Eval(ev);
-  const string&& str = args[2]->Eval(ev);
+void SubstFunc(const std::vector<Value*>& args, Evaluator* ev, std::string* s) {
+  const std::string&& pat = args[0]->Eval(ev);
+  const std::string&& repl = args[1]->Eval(ev);
+  const std::string&& str = args[2]->Eval(ev);
   if (pat.empty()) {
     *s += str;
     *s += repl;
@@ -130,7 +132,7 @@
   size_t index = 0;
   while (index < str.size()) {
     size_t found = str.find(pat, index);
-    if (found == string::npos)
+    if (found == std::string::npos)
       break;
     AppendString(StringPiece(str).substr(index, found - index), s);
     AppendString(repl, s);
@@ -139,17 +141,21 @@
   AppendString(StringPiece(str).substr(index), s);
 }
 
-void FindstringFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& find = args[0]->Eval(ev);
-  const string&& in = args[1]->Eval(ev);
-  if (in.find(find) != string::npos)
+void FindstringFunc(const std::vector<Value*>& args,
+                    Evaluator* ev,
+                    std::string* s) {
+  const std::string&& find = args[0]->Eval(ev);
+  const std::string&& in = args[1]->Eval(ev);
+  if (in.find(find) != std::string::npos)
     AppendString(find, s);
 }
 
-void FilterFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& pat_buf = args[0]->Eval(ev);
-  const string&& text = args[1]->Eval(ev);
-  vector<Pattern> pats;
+void FilterFunc(const std::vector<Value*>& args,
+                Evaluator* ev,
+                std::string* s) {
+  const std::string&& pat_buf = args[0]->Eval(ev);
+  const std::string&& text = args[1]->Eval(ev);
+  std::vector<Pattern> pats;
   for (StringPiece pat : WordScanner(pat_buf)) {
     pats.push_back(Pattern(pat));
   }
@@ -164,10 +170,12 @@
   }
 }
 
-void FilterOutFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& pat_buf = args[0]->Eval(ev);
-  const string&& text = args[1]->Eval(ev);
-  vector<Pattern> pats;
+void FilterOutFunc(const std::vector<Value*>& args,
+                   Evaluator* ev,
+                   std::string* s) {
+  const std::string&& pat_buf = args[0]->Eval(ev);
+  const std::string&& text = args[1]->Eval(ev);
+  std::vector<Pattern> pats;
   for (StringPiece pat : WordScanner(pat_buf)) {
     pats.push_back(Pattern(pat));
   }
@@ -185,13 +193,13 @@
   }
 }
 
-void SortFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  string list;
+void SortFunc(const std::vector<Value*>& args, Evaluator* ev, std::string* s) {
+  std::string list;
   args[0]->Eval(ev, &list);
   COLLECT_STATS("func sort time");
   // TODO(hamaji): Probably we could use a faster string-specific sort
   // algorithm.
-  vector<StringPiece> toks;
+  std::vector<StringPiece> toks;
   WordScanner(list).Split(&toks);
   stable_sort(toks.begin(), toks.end());
   WordWriter ww(s);
@@ -204,7 +212,7 @@
   }
 }
 
-static int GetNumericValueForFunc(const string& buf) {
+static int GetNumericValueForFunc(const std::string& buf) {
   StringPiece s = TrimLeftSpace(buf);
   char* end;
   long n = strtol(s.data(), &end, 10);
@@ -214,8 +222,8 @@
   return n;
 }
 
-void WordFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& n_str = args[0]->Eval(ev);
+void WordFunc(const std::vector<Value*>& args, Evaluator* ev, std::string* s) {
+  const std::string&& n_str = args[0]->Eval(ev);
   int n = GetNumericValueForFunc(n_str);
   if (n < 0) {
     ev->Error(
@@ -226,7 +234,7 @@
     ev->Error("*** first argument to `word' function must be greater than 0.");
   }
 
-  const string&& text = args[1]->Eval(ev);
+  const std::string&& text = args[1]->Eval(ev);
   for (StringPiece tok : WordScanner(text)) {
     n--;
     if (n == 0) {
@@ -236,8 +244,10 @@
   }
 }
 
-void WordlistFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& s_str = args[0]->Eval(ev);
+void WordlistFunc(const std::vector<Value*>& args,
+                  Evaluator* ev,
+                  std::string* s) {
+  const std::string&& s_str = args[0]->Eval(ev);
   int si = GetNumericValueForFunc(s_str);
   if (si < 0) {
     ev->Error(StringPrintf(
@@ -250,7 +260,7 @@
                      s_str.c_str()));
   }
 
-  const string&& e_str = args[1]->Eval(ev);
+  const std::string&& e_str = args[1]->Eval(ev);
   int ei = GetNumericValueForFunc(e_str);
   if (ei < 0) {
     ev->Error(StringPrintf(
@@ -258,7 +268,7 @@
         e_str.c_str()));
   }
 
-  const string&& text = args[2]->Eval(ev);
+  const std::string&& text = args[2]->Eval(ev);
   int i = 0;
   WordWriter ww(s);
   for (StringPiece tok : WordScanner(text)) {
@@ -269,8 +279,8 @@
   }
 }
 
-void WordsFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& text = args[0]->Eval(ev);
+void WordsFunc(const std::vector<Value*>& args, Evaluator* ev, std::string* s) {
+  const std::string&& text = args[0]->Eval(ev);
   WordScanner ws(text);
   int n = 0;
   for (auto iter = ws.begin(); iter != ws.end(); ++iter)
@@ -280,8 +290,10 @@
   *s += buf;
 }
 
-void FirstwordFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& text = args[0]->Eval(ev);
+void FirstwordFunc(const std::vector<Value*>& args,
+                   Evaluator* ev,
+                   std::string* s) {
+  const std::string&& text = args[0]->Eval(ev);
   WordScanner ws(text);
   auto begin = ws.begin();
   if (begin != ws.end()) {
@@ -289,8 +301,10 @@
   }
 }
 
-void LastwordFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& text = args[0]->Eval(ev);
+void LastwordFunc(const std::vector<Value*>& args,
+                  Evaluator* ev,
+                  std::string* s) {
+  const std::string&& text = args[0]->Eval(ev);
   StringPiece last;
   for (StringPiece tok : WordScanner(text)) {
     last = tok;
@@ -298,9 +312,9 @@
   AppendString(last, s);
 }
 
-void JoinFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& list1 = args[0]->Eval(ev);
-  const string&& list2 = args[1]->Eval(ev);
+void JoinFunc(const std::vector<Value*>& args, Evaluator* ev, std::string* s) {
+  const std::string&& list1 = args[0]->Eval(ev);
+  const std::string&& list2 = args[1]->Eval(ev);
   WordScanner ws1(list1);
   WordScanner ws2(list2);
   WordWriter ww(s);
@@ -317,8 +331,10 @@
     ww.Write(*iter2);
 }
 
-void WildcardFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& pat = args[0]->Eval(ev);
+void WildcardFunc(const std::vector<Value*>& args,
+                  Evaluator* ev,
+                  std::string* s) {
+  const std::string&& pat = args[0]->Eval(ev);
   COLLECT_STATS("func wildcard time");
   // Note GNU make does not delay the execution of $(wildcard) so we
   // do not need to check avoid_io here.
@@ -326,14 +342,14 @@
   for (StringPiece tok : WordScanner(pat)) {
     ScopedTerminator st(tok);
     const auto& files = Glob(tok.data());
-    for (const string& file : files) {
+    for (const std::string& file : files) {
       ww.Write(file);
     }
   }
 }
 
-void DirFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& text = args[0]->Eval(ev);
+void DirFunc(const std::vector<Value*>& args, Evaluator* ev, std::string* s) {
+  const std::string&& text = args[0]->Eval(ev);
   WordWriter ww(s);
   for (StringPiece tok : WordScanner(text)) {
     ww.Write(Dirname(tok));
@@ -341,8 +357,10 @@
   }
 }
 
-void NotdirFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& text = args[0]->Eval(ev);
+void NotdirFunc(const std::vector<Value*>& args,
+                Evaluator* ev,
+                std::string* s) {
+  const std::string&& text = args[0]->Eval(ev);
   WordWriter ww(s);
   for (StringPiece tok : WordScanner(text)) {
     if (tok == "/") {
@@ -353,8 +371,10 @@
   }
 }
 
-void SuffixFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& text = args[0]->Eval(ev);
+void SuffixFunc(const std::vector<Value*>& args,
+                Evaluator* ev,
+                std::string* s) {
+  const std::string&& text = args[0]->Eval(ev);
   WordWriter ww(s);
   for (StringPiece tok : WordScanner(text)) {
     StringPiece suf = GetExt(tok);
@@ -363,17 +383,21 @@
   }
 }
 
-void BasenameFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& text = args[0]->Eval(ev);
+void BasenameFunc(const std::vector<Value*>& args,
+                  Evaluator* ev,
+                  std::string* s) {
+  const std::string&& text = args[0]->Eval(ev);
   WordWriter ww(s);
   for (StringPiece tok : WordScanner(text)) {
     ww.Write(StripExt(tok));
   }
 }
 
-void AddsuffixFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& suf = args[0]->Eval(ev);
-  const string&& text = args[1]->Eval(ev);
+void AddsuffixFunc(const std::vector<Value*>& args,
+                   Evaluator* ev,
+                   std::string* s) {
+  const std::string&& suf = args[0]->Eval(ev);
+  const std::string&& text = args[1]->Eval(ev);
   WordWriter ww(s);
   for (StringPiece tok : WordScanner(text)) {
     ww.Write(tok);
@@ -381,9 +405,11 @@
   }
 }
 
-void AddprefixFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& pre = args[0]->Eval(ev);
-  const string&& text = args[1]->Eval(ev);
+void AddprefixFunc(const std::vector<Value*>& args,
+                   Evaluator* ev,
+                   std::string* s) {
+  const std::string&& pre = args[0]->Eval(ev);
+  const std::string&& text = args[1]->Eval(ev);
   WordWriter ww(s);
   for (StringPiece tok : WordScanner(text)) {
     ww.Write(pre);
@@ -391,8 +417,10 @@
   }
 }
 
-void RealpathFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& text = args[0]->Eval(ev);
+void RealpathFunc(const std::vector<Value*>& args,
+                  Evaluator* ev,
+                  std::string* s) {
+  const std::string&& text = args[0]->Eval(ev);
   if (ev->avoid_io()) {
     *s += "$(";
     *s += GetExecutablePath();
@@ -411,18 +439,20 @@
   }
 }
 
-void AbspathFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& text = args[0]->Eval(ev);
+void AbspathFunc(const std::vector<Value*>& args,
+                 Evaluator* ev,
+                 std::string* s) {
+  const std::string&& text = args[0]->Eval(ev);
   WordWriter ww(s);
-  string buf;
+  std::string buf;
   for (StringPiece tok : WordScanner(text)) {
     AbsPath(tok, &buf);
     ww.Write(buf);
   }
 }
 
-void IfFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& cond = args[0]->Eval(ev);
+void IfFunc(const std::vector<Value*>& args, Evaluator* ev, std::string* s) {
+  const std::string&& cond = args[0]->Eval(ev);
   if (cond.empty()) {
     if (args.size() > 2)
       args[2]->Eval(ev, s);
@@ -431,8 +461,8 @@
   }
 }
 
-void AndFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  string cond;
+void AndFunc(const std::vector<Value*>& args, Evaluator* ev, std::string* s) {
+  std::string cond;
   for (Value* a : args) {
     cond = a->Eval(ev);
     if (cond.empty())
@@ -443,9 +473,9 @@
   }
 }
 
-void OrFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
+void OrFunc(const std::vector<Value*>& args, Evaluator* ev, std::string* s) {
   for (Value* a : args) {
-    const string&& cond = a->Eval(ev);
+    const std::string&& cond = a->Eval(ev);
     if (!cond.empty()) {
       *s += cond;
       return;
@@ -453,24 +483,24 @@
   }
 }
 
-void ValueFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& var_name = args[0]->Eval(ev);
+void ValueFunc(const std::vector<Value*>& args, Evaluator* ev, std::string* s) {
+  const std::string&& var_name = args[0]->Eval(ev);
   Var* var = ev->LookupVar(Intern(var_name));
   AppendString(var->String().as_string(), s);
 }
 
-void EvalFunc(const vector<Value*>& args, Evaluator* ev, string*) {
+void EvalFunc(const std::vector<Value*>& args, Evaluator* ev, std::string*) {
   // TODO: eval leaks everything... for now.
   // const string text = args[0]->Eval(ev);
   ev->CheckStack();
-  string* text = new string;
+  std::string* text = new std::string;
   args[0]->Eval(ev, text);
   if (ev->avoid_io()) {
     KATI_WARN_LOC(ev->loc(),
                   "*warning*: $(eval) in a recipe is not recommended: %s",
                   text->c_str());
   }
-  vector<Stmt*> stmts;
+  std::vector<Stmt*> stmts;
   Parse(*text, ev->loc(), &stmts);
   for (Stmt* stmt : stmts) {
     LOG("%s", stmt->DebugString().c_str());
@@ -486,7 +516,7 @@
 // will be passed to other make functions.
 // TODO: Maybe we should introduce a helper binary which evaluate
 // make expressions at ninja-time.
-static bool HasNoIoInShellScript(const string& cmd) {
+static bool HasNoIoInShellScript(const std::string& cmd) {
   if (cmd.empty())
     return true;
   if (HasPrefix(cmd, "echo $((") && cmd[cmd.size() - 1] == ')')
@@ -494,11 +524,11 @@
   return false;
 }
 
-static int ShellFuncImpl(const string& shell,
-                         const string& shellflag,
-                         const string& cmd,
+static int ShellFuncImpl(const std::string& shell,
+                         const std::string& shellflag,
+                         const std::string& cmd,
                          const Loc& loc,
-                         string* s,
+                         std::string* s,
                          FindCommand** fc) {
   LOG("ShellFunc: %s", cmd.c_str());
 
@@ -542,7 +572,7 @@
   return 1;
 }
 
-static vector<CommandResult*> g_command_results;
+static std::vector<CommandResult*> g_command_results;
 
 bool ShouldStoreCommandResult(StringPiece cmd) {
   // We really just want to ignore this one, or remove BUILD_DATETIME from
@@ -561,8 +591,8 @@
   return true;
 }
 
-void ShellFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  string cmd = args[0]->Eval(ev);
+void ShellFunc(const std::vector<Value*>& args, Evaluator* ev, std::string* s) {
+  std::string cmd = args[0]->Eval(ev);
   if (ev->avoid_io() && !HasNoIoInShellScript(cmd)) {
     if (ev->eval_depth() > 1) {
       ERROR_LOC(ev->loc(),
@@ -577,10 +607,10 @@
     return;
   }
 
-  const string&& shell = ev->GetShell();
-  const string&& shellflag = ev->GetShellFlag();
+  const std::string&& shell = ev->GetShell();
+  const std::string&& shellflag = ev->GetShellFlag();
 
-  string out;
+  std::string out;
   FindCommand* fc = NULL;
   int returnCode = ShellFuncImpl(shell, shellflag, cmd, ev->loc(), &out, &fc);
   if (ShouldStoreCommandResult(cmd)) {
@@ -598,13 +628,13 @@
   ShellStatusVar::SetValue(returnCode);
 }
 
-void CallFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
+void CallFunc(const std::vector<Value*>& args, Evaluator* ev, std::string* s) {
   static const Symbol tmpvar_names[] = {
       Intern("0"), Intern("1"), Intern("2"), Intern("3"), Intern("4"),
       Intern("5"), Intern("6"), Intern("7"), Intern("8"), Intern("9")};
 
   ev->CheckStack();
-  const string&& func_name_buf = args[0]->Eval(ev);
+  const std::string&& func_name_buf = args[0]->Eval(ev);
   Symbol func_sym = Intern(TrimSpace(func_name_buf));
   Var* func = ev->LookupVar(func_sym);
   func->Used(ev, func_sym);
@@ -612,14 +642,14 @@
     KATI_WARN_LOC(ev->loc(), "*warning*: undefined user function: %s",
                   func_sym.c_str());
   }
-  vector<unique_ptr<SimpleVar>> av;
+  std::vector<std::unique_ptr<SimpleVar>> av;
   for (size_t i = 1; i < args.size(); i++) {
     av.emplace_back(std::make_unique<SimpleVar>(
         args[i]->Eval(ev), VarOrigin::AUTOMATIC, nullptr, Loc()));
   }
-  vector<unique_ptr<ScopedGlobalVar>> sv;
+  std::vector<std::unique_ptr<ScopedGlobalVar>> sv;
   for (size_t i = 1;; i++) {
-    string s;
+    std::string s;
     Symbol tmpvar_name_sym;
     if (i < sizeof(tmpvar_names) / sizeof(tmpvar_names[0])) {
       tmpvar_name_sym = tmpvar_names[i];
@@ -652,13 +682,15 @@
   ev->IncrementEvalDepth();
 }
 
-void ForeachFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& varname = args[0]->Eval(ev);
-  const string&& list = args[1]->Eval(ev);
+void ForeachFunc(const std::vector<Value*>& args,
+                 Evaluator* ev,
+                 std::string* s) {
+  const std::string&& varname = args[0]->Eval(ev);
+  const std::string&& list = args[1]->Eval(ev);
   ev->DecrementEvalDepth();
   WordWriter ww(s);
   for (StringPiece tok : WordScanner(list)) {
-    unique_ptr<SimpleVar> v(
+    std::unique_ptr<SimpleVar> v(
         new SimpleVar(tok.as_string(), VarOrigin::AUTOMATIC, nullptr, Loc()));
     ScopedGlobalVar sv(Intern(varname), v.get());
     ww.MaybeAddWhitespace();
@@ -667,20 +699,24 @@
   ev->IncrementEvalDepth();
 }
 
-void OriginFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& var_name = args[0]->Eval(ev);
+void OriginFunc(const std::vector<Value*>& args,
+                Evaluator* ev,
+                std::string* s) {
+  const std::string&& var_name = args[0]->Eval(ev);
   Var* var = ev->LookupVar(Intern(var_name));
   *s += GetOriginStr(var->Origin());
 }
 
-void FlavorFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
-  const string&& var_name = args[0]->Eval(ev);
+void FlavorFunc(const std::vector<Value*>& args,
+                Evaluator* ev,
+                std::string* s) {
+  const std::string&& var_name = args[0]->Eval(ev);
   Var* var = ev->LookupVar(Intern(var_name));
   *s += var->Flavor();
 }
 
-void InfoFunc(const vector<Value*>& args, Evaluator* ev, string*) {
-  const string&& a = args[0]->Eval(ev);
+void InfoFunc(const std::vector<Value*>& args, Evaluator* ev, std::string*) {
+  const std::string&& a = args[0]->Eval(ev);
   if (ev->avoid_io()) {
     ev->add_delayed_output_command(
         StringPrintf("echo -e \"%s\"", EchoEscape(a).c_str()));
@@ -690,8 +726,8 @@
   fflush(stdout);
 }
 
-void WarningFunc(const vector<Value*>& args, Evaluator* ev, string*) {
-  const string&& a = args[0]->Eval(ev);
+void WarningFunc(const std::vector<Value*>& args, Evaluator* ev, std::string*) {
+  const std::string&& a = args[0]->Eval(ev);
   if (ev->avoid_io()) {
     ev->add_delayed_output_command(StringPrintf(
         "echo -e \"%s:%d: %s\" 2>&1", LOCF(ev->loc()), EchoEscape(a).c_str()));
@@ -700,8 +736,8 @@
   WARN_LOC(ev->loc(), "%s", a.c_str());
 }
 
-void ErrorFunc(const vector<Value*>& args, Evaluator* ev, string*) {
-  const string&& a = args[0]->Eval(ev);
+void ErrorFunc(const std::vector<Value*>& args, Evaluator* ev, std::string*) {
+  const std::string&& a = args[0]->Eval(ev);
   if (ev->avoid_io()) {
     ev->add_delayed_output_command(
         StringPrintf("echo -e \"%s:%d: *** %s.\" 2>&1 && false",
@@ -711,7 +747,9 @@
   ev->Error(StringPrintf("*** %s.", a.c_str()));
 }
 
-static void FileReadFunc(Evaluator* ev, const string& filename, string* s) {
+static void FileReadFunc(Evaluator* ev,
+                         const std::string& filename,
+                         std::string* s) {
   int fd = open(filename.c_str(), O_RDONLY);
   if (fd < 0) {
     if (errno == ENOENT) {
@@ -734,7 +772,7 @@
   }
 
   size_t len = st.st_size;
-  string out;
+  std::string out;
   out.resize(len);
   ssize_t r = HANDLE_EINTR(read(fd, &out[0], len));
   if (r != static_cast<ssize_t>(len)) {
@@ -760,9 +798,9 @@
 }
 
 static void FileWriteFunc(Evaluator* ev,
-                          const string& filename,
+                          const std::string& filename,
                           bool append,
-                          string text) {
+                          std::string text) {
   FILE* f = fopen(filename.c_str(), append ? "ab" : "wb");
   if (f == NULL) {
     ev->Error("*** fopen failed.");
@@ -786,12 +824,12 @@
   }
 }
 
-void FileFunc(const vector<Value*>& args, Evaluator* ev, string* s) {
+void FileFunc(const std::vector<Value*>& args, Evaluator* ev, std::string* s) {
   if (ev->avoid_io()) {
     ev->Error("*** $(file ...) is not supported in rules.");
   }
 
-  string arg = args[0]->Eval(ev);
+  std::string arg = args[0]->Eval(ev);
   StringPiece filename = TrimSpace(arg);
 
   if (filename.size() <= 1) {
@@ -821,7 +859,7 @@
       ev->Error("*** Missing filename");
     }
 
-    string text;
+    std::string text;
     if (args.size() > 1) {
       text = args[1]->Eval(ev);
       if (text.size() == 0 || text.back() != '\n') {
@@ -836,9 +874,11 @@
   }
 }
 
-void DeprecatedVarFunc(const vector<Value*>& args, Evaluator* ev, string*) {
-  string vars_str = args[0]->Eval(ev);
-  string msg;
+void DeprecatedVarFunc(const std::vector<Value*>& args,
+                       Evaluator* ev,
+                       std::string*) {
+  std::string vars_str = args[0]->Eval(ev);
+  std::string msg;
 
   if (args.size() == 2) {
     msg = ". " + args[1]->Eval(ev);
@@ -872,9 +912,11 @@
   }
 }
 
-void ObsoleteVarFunc(const vector<Value*>& args, Evaluator* ev, string*) {
-  string vars_str = args[0]->Eval(ev);
-  string msg;
+void ObsoleteVarFunc(const std::vector<Value*>& args,
+                     Evaluator* ev,
+                     std::string*) {
+  std::string vars_str = args[0]->Eval(ev);
+  std::string msg;
 
   if (args.size() == 2) {
     msg = ". " + args[1]->Eval(ev);
@@ -907,8 +949,10 @@
   }
 }
 
-void DeprecateExportFunc(const vector<Value*>& args, Evaluator* ev, string*) {
-  string msg = ". " + args[0]->Eval(ev);
+void DeprecateExportFunc(const std::vector<Value*>& args,
+                         Evaluator* ev,
+                         std::string*) {
+  std::string msg = ". " + args[0]->Eval(ev);
 
   if (ev->avoid_io()) {
     ev->Error("*** $(KATI_deprecate_export) is not supported in rules.");
@@ -923,8 +967,10 @@
   ev->SetExportDeprecated(msg);
 }
 
-void ObsoleteExportFunc(const vector<Value*>& args, Evaluator* ev, string*) {
-  string msg = ". " + args[0]->Eval(ev);
+void ObsoleteExportFunc(const std::vector<Value*>& args,
+                        Evaluator* ev,
+                        std::string*) {
+  std::string msg = ". " + args[0]->Eval(ev);
 
   if (ev->avoid_io()) {
     ev->Error("*** $(KATI_obsolete_export) is not supported in rules.");
@@ -937,19 +983,19 @@
   ev->SetExportObsolete(msg);
 }
 
-void ProfileFunc(const vector<Value*>& args, Evaluator* ev, string*) {
+void ProfileFunc(const std::vector<Value*>& args, Evaluator* ev, std::string*) {
   for (auto arg : args) {
-    string files = arg->Eval(ev);
+    std::string files = arg->Eval(ev);
     for (StringPiece file : WordScanner(files)) {
       ev->ProfileMakefile(file);
     }
   }
 }
 
-void VariableLocationFunc(const vector<Value*>& args,
+void VariableLocationFunc(const std::vector<Value*>& args,
                           Evaluator* ev,
-                          string* s) {
-  string arg = args[0]->Eval(ev);
+                          std::string* s) {
+  std::string arg = args[0]->Eval(ev);
   WordWriter ww(s);
   for (StringPiece var : WordScanner(arg)) {
     Symbol sym = Intern(var);
@@ -1030,6 +1076,6 @@
   return &found->second;
 }
 
-const vector<CommandResult*>& GetShellCommandResults() {
+const std::vector<CommandResult*>& GetShellCommandResults() {
   return g_command_results;
 }
diff --git a/src/func.h b/src/func.h
index 206a363..f6287f5 100644
--- a/src/func.h
+++ b/src/func.h
@@ -22,11 +22,9 @@
 #include "expr.h"
 #include "loc.h"
 
-using namespace std;
-
 struct FuncInfo {
   const char* name;
-  void (*func)(const vector<Value*>& args, Evaluator* ev, string* s);
+  void (*func)(const std::vector<Value*>& args, Evaluator* ev, std::string* s);
   int arity;
   int min_arity;
   // For all parameters.
@@ -50,14 +48,14 @@
 
 struct CommandResult {
   CommandOp op;
-  string shell;
-  string shellflag;
-  string cmd;
-  unique_ptr<FindCommand> find;
-  string result;
+  std::string shell;
+  std::string shellflag;
+  std::string cmd;
+  std::unique_ptr<FindCommand> find;
+  std::string result;
   Loc loc;
 };
 
-const vector<CommandResult*>& GetShellCommandResults();
+const std::vector<CommandResult*>& GetShellCommandResults();
 
 #endif  // FUNC_H_
diff --git a/src/io.cc b/src/io.cc
index 9ae1c5e..75d8940 100644
--- a/src/io.cc
+++ b/src/io.cc
@@ -37,7 +37,7 @@
   return v;
 }
 
-bool LoadString(FILE* fp, string* s) {
+bool LoadString(FILE* fp, std::string* s) {
   int len = LoadInt(fp);
   if (len < 0)
     return false;
diff --git a/src/io.h b/src/io.h
index 28316f4..eb84910 100644
--- a/src/io.h
+++ b/src/io.h
@@ -21,13 +21,11 @@
 
 #include "string_piece.h"
 
-using namespace std;
-
 void DumpInt(FILE* fp, int v);
 void DumpString(FILE* fp, StringPiece s);
 
 int LoadInt(FILE* fp);
-bool LoadString(FILE* fp, string* s);
+bool LoadString(FILE* fp, std::string* s);
 
 struct ScopedFile {
  public:
diff --git a/src/log.cc b/src/log.cc
index 62f2422..2b19018 100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -59,4 +59,4 @@
 }
 
 bool g_log_no_exit;
-string* g_last_error;
+std::string* g_last_error;
diff --git a/src/log.h b/src/log.h
index ba0bd8b..80aef86 100644
--- a/src/log.h
+++ b/src/log.h
@@ -24,10 +24,8 @@
 #include "log.h"
 #include "stringprintf.h"
 
-using namespace std;
-
 extern bool g_log_no_exit;
-extern string* g_last_error;
+extern std::string* g_last_error;
 
 // Useful for logging-only arguments.
 #define UNUSED __attribute__((unused))
@@ -76,7 +74,7 @@
       fprintf(stderr, "%s\n", StringPrintf(__VA_ARGS__).c_str()); \
       exit(1);                                                    \
     }                                                             \
-    g_last_error = new string(StringPrintf(__VA_ARGS__));         \
+    g_last_error = new std::string(StringPrintf(__VA_ARGS__));    \
   } while (0)
 
 #define CHECK(c) \
diff --git a/src/main.cc b/src/main.cc
index 417ec2c..609aaea 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -49,9 +49,9 @@
   return "detect_leaks=0:allow_user_segv_handler=1";
 }
 
-static void ReadBootstrapMakefile(const vector<Symbol>& targets,
-                                  vector<Stmt*>* stmts) {
-  string bootstrap =
+static void ReadBootstrapMakefile(const std::vector<Symbol>& targets,
+                                  std::vector<Stmt*>* stmts) {
+  std::string bootstrap =
       ("CC?=cc\n"
 #if defined(__APPLE__)
        "CXX?=c++\n"
@@ -103,7 +103,7 @@
                    Frame* definition,
                    Loc loc) {
   size_t found = l.find('=');
-  CHECK(found != string::npos);
+  CHECK(found != std::string::npos);
   Symbol lhs = Intern(l.substr(0, found));
   StringPiece rhs = l.substr(found + 1);
   lhs.SetGlobalVar(new RecursiveVar(Value::NewLiteral(rhs.data()), origin,
@@ -203,9 +203,9 @@
   global_handler = nullptr;
 }
 
-static int Run(const vector<Symbol>& targets,
-               const vector<StringPiece>& cl_vars,
-               const string& orig_args) {
+static int Run(const std::vector<Symbol>& targets,
+               const std::vector<StringPiece>& cl_vars,
+               const std::string& orig_args) {
   double start_time = GetTime();
 
   if (g_flags.generate_ninja && (g_flags.regen || g_flags.dump_kati_stamp)) {
@@ -236,7 +236,7 @@
   }
   SegfaultHandler segfault(&ev);
 
-  vector<Stmt*> bootstrap_asts;
+  std::vector<Stmt*> bootstrap_asts;
   ReadBootstrapMakefile(targets, &bootstrap_asts);
 
   {
@@ -252,7 +252,7 @@
     ScopedFrame frame(ev.Enter(FrameType::PHASE, "*command line*", Loc()));
     ev.in_command_line();
     for (StringPiece l : cl_vars) {
-      vector<Stmt*> asts;
+      std::vector<Stmt*> asts;
       Parse(Intern(l).str(), Loc("*bootstrap*", 0), &asts);
       CHECK(asts.size() == 1);
       asts[0]->Eval(&ev);
@@ -282,7 +282,7 @@
     ev.DumpIncludeJSON(std::string(g_flags.dump_include_graph));
   }
 
-  vector<NamedDepNode> nodes;
+  std::vector<NamedDepNode> nodes;
   {
     ScopedFrame frame(
         ev.Enter(FrameType::PHASE, "*dependency analysis*", Loc()));
@@ -306,7 +306,7 @@
     const Symbol name = p.first;
     if (p.second) {
       Var* v = ev.LookupVar(name);
-      const string&& value = v->Eval(&ev);
+      const std::string&& value = v->Eval(&ev);
       LOG("setenv(%s, %s)", name.c_str(), value.c_str());
       setenv(name.c_str(), value.c_str(), 1);
     } else {
@@ -357,7 +357,7 @@
     HandleRealpath(argc - 2, argv + 2);
     return 0;
   }
-  string orig_args;
+  std::string orig_args;
   for (int i = 0; i < argc; i++) {
     if (i)
       orig_args += ' ';
diff --git a/src/ninja.cc b/src/ninja.cc
index 11d713f..e29e965 100644
--- a/src/ninja.cc
+++ b/src/ninja.cc
@@ -817,15 +817,15 @@
   const DepNode* default_target_;
 };
 
-string GetNinjaFilename() {
+std::string GetNinjaFilename() {
   return NinjaGenerator::GetFilename("build%s.ninja");
 }
 
-string GetNinjaShellScriptFilename() {
+std::string GetNinjaShellScriptFilename() {
   return NinjaGenerator::GetFilename("ninja%s.sh");
 }
 
-string GetNinjaStampFilename() {
+std::string GetNinjaStampFilename() {
   return NinjaGenerator::GetFilename(".kati_stamp%s");
 }
 
diff --git a/src/ninja.h b/src/ninja.h
index 281ce2c..932d186 100644
--- a/src/ninja.h
+++ b/src/ninja.h
@@ -30,9 +30,9 @@
                    const std::string& orig_args,
                    double start_time);
 
-string GetNinjaFilename();
-string GetNinjaShellScriptFilename();
-string GetNinjaStampFilename();
+std::string GetNinjaFilename();
+std::string GetNinjaShellScriptFilename();
+std::string GetNinjaStampFilename();
 
 // Exposed only for test.
 bool GetDepfileFromCommand(std::string* cmd, std::string* out);
diff --git a/src/ninja_test.cc b/src/ninja_test.cc
index 15b0693..f46d2bb 100644
--- a/src/ninja_test.cc
+++ b/src/ninja_test.cc
@@ -23,9 +23,9 @@
 
 namespace {
 
-string GetDepfile(string cmd, string* new_cmd) {
+std::string GetDepfile(std::string cmd, std::string* new_cmd) {
   new_cmd->clear();
-  string r;
+  std::string r;
   if (GetDepfileFromCommand(&cmd, &r)) {
     *new_cmd = cmd;
     return r;
@@ -34,7 +34,7 @@
 }
 
 void TestGetDepfile() {
-  string new_cmd;
+  std::string new_cmd;
   ASSERT_EQ(GetDepfile("g++ -c fat.cc -MD ", &new_cmd), "");
   assert(g_last_error);
   delete g_last_error;
@@ -74,7 +74,8 @@
                 "prebuilts/misc/linux-x86/ccache/ccache "
                 "prebuilts/clang/linux-x86/host/3.6/bin/clang++ -c foo.c"),
             39);
-  ASSERT_EQ(GetGomaccPosForAndroidCompileCommand("echo foo"), string::npos);
+  ASSERT_EQ(GetGomaccPosForAndroidCompileCommand("echo foo"),
+            std::string::npos);
 }
 
 }  // namespace
diff --git a/src/parser.cc b/src/parser.cc
index 9db7ac0..323d9f6 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -43,10 +43,10 @@
 
   typedef void (Parser::*DirectiveHandler)(StringPiece line,
                                            StringPiece directive);
-  typedef unordered_map<StringPiece, DirectiveHandler> DirectiveMap;
+  typedef std::unordered_map<StringPiece, DirectiveHandler> DirectiveMap;
 
  public:
-  Parser(StringPiece buf, const char* filename, vector<Stmt*>* stmts)
+  Parser(StringPiece buf, const char* filename, std::vector<Stmt*>* stmts)
       : buf_(buf),
         state_(ParserState::NOT_AFTER_RULE),
         stmts_(stmts),
@@ -56,7 +56,7 @@
         loc_(filename, 0),
         fixed_lineno_(false) {}
 
-  Parser(StringPiece buf, const Loc& loc, vector<Stmt*>* stmts)
+  Parser(StringPiece buf, const Loc& loc, std::vector<Stmt*>* stmts)
       : buf_(buf),
         state_(ParserState::NOT_AFTER_RULE),
         stmts_(stmts),
@@ -95,10 +95,10 @@
 
   void set_state(ParserState st) { state_ = st; }
 
-  static vector<ParseErrorStmt*> parse_errors;
+  static std::vector<ParseErrorStmt*> parse_errors;
 
  private:
-  void Error(const string& msg) {
+  void Error(const std::string& msg) {
     ParseErrorStmt* stmt = new ParseErrorStmt();
     stmt->set_loc(loc_);
     stmt->msg = msg;
@@ -152,8 +152,8 @@
 
   void ParseRuleOrAssign(StringPiece line) {
     size_t sep = FindThreeOutsideParen(line, ':', '=', ';');
-    if (sep == string::npos || line[sep] == ';') {
-      ParseRule(line, string::npos);
+    if (sep == std::string::npos || line[sep] == ';') {
+      ParseRule(line, std::string::npos);
     } else if (line[sep] == '=') {
       ParseAssign(line, sep);
     } else if (line.get(sep + 1) == '=') {
@@ -169,7 +169,7 @@
     if (current_directive_ != AssignDirective::NONE) {
       if (IsInExport())
         return;
-      if (sep != string::npos) {
+      if (sep != std::string::npos) {
         sep += orig_line_with_directives_.size() - line.size();
       }
       line = orig_line_with_directives_;
@@ -184,13 +184,13 @@
       return;
     }
 
-    const bool is_rule = sep != string::npos && line[sep] == ':';
+    const bool is_rule = sep != std::string::npos && line[sep] == ':';
     RuleStmt* rule_stmt = new RuleStmt();
     rule_stmt->set_loc(loc_);
 
     size_t found = FindTwoOutsideParen(line.substr(sep + 1), '=', ';');
     Loc mutable_loc(loc_);
-    if (found != string::npos) {
+    if (found != std::string::npos) {
       found += sep + 1;
       rule_stmt->lhs =
           ParseExpr(&mutable_loc, TrimSpace(line.substr(0, found)));
@@ -355,7 +355,7 @@
         if (quote != '\'' && quote != '"')
           return false;
         size_t end = s.find(quote, 1);
-        if (end == string::npos)
+        if (end == std::string::npos)
           return false;
         Value* v =
             ParseExpr(&mutable_loc, s.substr(1, end - 1), ParseExprOpt::NORMAL);
@@ -481,7 +481,7 @@
 
   StringPiece RemoveComment(StringPiece line) {
     size_t i = FindOutsideParen(line, '#');
-    if (i == string::npos)
+    if (i == std::string::npos)
       return line;
     return line.substr(0, i);
   }
@@ -510,8 +510,8 @@
   size_t l_;
   ParserState state_;
 
-  vector<Stmt*>* stmts_;
-  vector<Stmt*>* out_stmts_;
+  std::vector<Stmt*>* stmts_;
+  std::vector<Stmt*>* out_stmts_;
 
   StringPiece define_name_;
   int num_define_nest_;
@@ -522,7 +522,7 @@
   AssignDirective current_directive_;
 
   int num_if_nest_;
-  stack<IfState*> if_stack_;
+  std::stack<IfState*> if_stack_;
 
   Loc loc_;
   bool fixed_lineno_;
@@ -541,7 +541,7 @@
   parser.Parse();
 }
 
-void Parse(StringPiece buf, const Loc& loc, vector<Stmt*>* out_stmts) {
+void Parse(StringPiece buf, const Loc& loc, std::vector<Stmt*>* out_stmts) {
   COLLECT_STATS("parse eval time");
   Parser parser(buf, loc, out_stmts);
   parser.Parse();
@@ -549,7 +549,7 @@
 
 void ParseNotAfterRule(StringPiece buf,
                        const Loc& loc,
-                       vector<Stmt*>* out_stmts) {
+                       std::vector<Stmt*>* out_stmts) {
   Parser parser(buf, loc, out_stmts);
   parser.set_state(ParserState::NOT_AFTER_RULE);
   parser.Parse();
@@ -595,7 +595,7 @@
   return result;
 }();
 
-vector<ParseErrorStmt*> Parser::parse_errors;
+std::vector<ParseErrorStmt*> Parser::parse_errors;
 
 void ParseAssignStatement(StringPiece line,
                           size_t sep,
@@ -623,6 +623,6 @@
   *rhs = TrimLeftSpace(line.substr(sep + 1));
 }
 
-const vector<ParseErrorStmt*>& GetParseErrors() {
+const std::vector<ParseErrorStmt*>& GetParseErrors() {
   return Parser::parse_errors;
 }
diff --git a/src/parser.h b/src/parser.h
index e42ef5b..ad855df 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -21,15 +21,13 @@
 #include "stmt.h"
 #include "string_piece.h"
 
-using namespace std;
-
 class Makefile;
 
 void Parse(Makefile* mk);
-void Parse(StringPiece buf, const Loc& loc, vector<Stmt*>* out_asts);
+void Parse(StringPiece buf, const Loc& loc, std::vector<Stmt*>* out_asts);
 void ParseNotAfterRule(StringPiece buf,
                        const Loc& loc,
-                       vector<Stmt*>* out_asts);
+                       std::vector<Stmt*>* out_asts);
 
 void ParseAssignStatement(StringPiece line,
                           size_t sep,
@@ -37,6 +35,6 @@
                           StringPiece* rhs,
                           AssignOp* op);
 
-const vector<ParseErrorStmt*>& GetParseErrors();
+const std::vector<ParseErrorStmt*>& GetParseErrors();
 
 #endif  // PARSER_H_
diff --git a/src/regen.cc b/src/regen.cc
index ee2559f..d32d025 100644
--- a/src/regen.cc
+++ b/src/regen.cc
@@ -52,19 +52,19 @@
 
 class StampChecker {
   struct GlobResult {
-    string pat;
-    vector<string> result;
+    std::string pat;
+    std::vector<std::string> result;
   };
 
   struct ShellResult {
     CommandOp op;
-    string shell;
-    string shellflag;
-    string cmd;
-    string result;
-    vector<string> missing_dirs;
-    vector<string> files;
-    vector<string> read_dirs;
+    std::string shell;
+    std::string shellflag;
+    std::string cmd;
+    std::string result;
+    std::vector<std::string> missing_dirs;
+    std::vector<std::string> files;
+    std::vector<std::string> read_dirs;
   };
 
  public:
@@ -79,7 +79,7 @@
     }
   }
 
-  bool NeedsRegen(double start_time, const string& orig_args) {
+  bool NeedsRegen(double start_time, const std::string& orig_args) {
     if (IsMissingOutputs())
       RETURN_TRUE;
 
@@ -117,7 +117,7 @@
     return false;
   }
 
-  bool CheckStep1(const string& orig_args) {
+  bool CheckStep1(const std::string& orig_args) {
 #define LOAD_INT(fp)                                               \
   ({                                                               \
     int v = LoadInt(fp);                                           \
@@ -136,7 +136,7 @@
     }                                                              \
   })
 
-    const string& stamp_filename = GetNinjaStampFilename();
+    const std::string& stamp_filename = GetNinjaStampFilename();
     FILE* fp = fopen(stamp_filename.c_str(), "rb");
     if (!fp) {
       if (g_flags.regen_debug)
@@ -155,7 +155,7 @@
     if (g_flags.regen_debug)
       printf("Generated time: %f\n", gen_time);
 
-    string s, s2;
+    std::string s, s2;
     int num_files = LOAD_INT(fp);
     for (int i = 0; i < num_files; i++) {
       LOAD_STRING(fp, &s);
@@ -220,7 +220,7 @@
     }
 
     int num_globs = LOAD_INT(fp);
-    string pat;
+    std::string pat;
     for (int i = 0; i < num_globs; i++) {
       GlobResult* gr = new GlobResult;
       globs_.push_back(gr);
@@ -243,7 +243,7 @@
       LOAD_STRING(fp, &sr->cmd);
       LOAD_STRING(fp, &sr->result);
 
-      string file;
+      std::string file;
       // Ignore debug info
       LOAD_STRING(fp, &file);
       LOAD_INT(fp);
@@ -276,7 +276,7 @@
     return needs_regen_;
   }
 
-  bool CheckGlobResult(const GlobResult* gr, string* err) {
+  bool CheckGlobResult(const GlobResult* gr, std::string* err) {
     COLLECT_STATS("glob time (regen)");
     const auto& files = Glob(gr->pat.c_str());
     bool needs_regen = files.size() != gr->result.size();
@@ -312,15 +312,15 @@
       return true;
 
     COLLECT_STATS("stat time (regen)");
-    for (const string& dir : sr->missing_dirs) {
+    for (const std::string& dir : sr->missing_dirs) {
       if (Exists(dir))
         return true;
     }
-    for (const string& file : sr->files) {
+    for (const std::string& file : sr->files) {
       if (!Exists(file))
         return true;
     }
-    for (const string& dir : sr->read_dirs) {
+    for (const std::string& dir : sr->read_dirs) {
       // We assume we rarely do a significant change for the top
       // directory which affects the results of find command.
       if (dir == "" || dir == "." || ShouldIgnoreDirty(dir))
@@ -343,7 +343,7 @@
     return false;
   }
 
-  bool CheckShellResult(const ShellResult* sr, string* err) {
+  bool CheckShellResult(const ShellResult* sr, std::string* err) {
     if (sr->op == CommandOp::READ_MISSING) {
       if (Exists(sr->cmd)) {
         if (g_flags.dump_kati_stamp)
@@ -407,7 +407,7 @@
     }
 
     COLLECT_STATS_WITH_SLOW_REPORT("shell time (regen)", sr->cmd.c_str());
-    string result;
+    std::string result;
     RunCommand(sr->shell, sr->shellflag, sr->cmd, RedirectStderr::DEV_NULL,
                &result);
     FormatForCommandSubstitution(&result);
@@ -428,12 +428,12 @@
 
   bool CheckStep2() {
     auto glob_future = std::async([this]() {
-      string err;
+      std::string err;
       // TODO: Make glob cache thread safe and create a task for each glob.
       SetAffinityForSingleThread();
       for (GlobResult* gr : globs_) {
         if (CheckGlobResult(gr, &err)) {
-          unique_lock<mutex> lock(mu_);
+          std::unique_lock<std::mutex> lock(mu_);
           if (!needs_regen_) {
             needs_regen_ = true;
             msg_ = err;
@@ -446,9 +446,9 @@
     auto shell_future = std::async([this]() {
       SetAffinityForSingleThread();
       for (ShellResult* sr : commands_) {
-        string err;
+        std::string err;
         if (CheckShellResult(sr, &err)) {
-          unique_lock<mutex> lock(mu_);
+          std::unique_lock<std::mutex> lock(mu_);
           if (!needs_regen_) {
             needs_regen_ = true;
             msg_ = err;
@@ -467,15 +467,15 @@
 
  private:
   double gen_time_;
-  vector<GlobResult*> globs_;
-  vector<ShellResult*> commands_;
-  mutex mu_;
+  std::vector<GlobResult*> globs_;
+  std::vector<ShellResult*> commands_;
+  std::mutex mu_;
   bool needs_regen_;
-  string msg_;
+  std::string msg_;
 };
 
 }  // namespace
 
-bool NeedsRegen(double start_time, const string& orig_args) {
+bool NeedsRegen(double start_time, const std::string& orig_args) {
   return StampChecker().NeedsRegen(start_time, orig_args);
 }
diff --git a/src/regen.h b/src/regen.h
index 3d43d70..91f67f1 100644
--- a/src/regen.h
+++ b/src/regen.h
@@ -17,8 +17,6 @@
 
 #include <string>
 
-using namespace std;
-
-bool NeedsRegen(double start_time, const string& orig_args);
+bool NeedsRegen(double start_time, const std::string& orig_args);
 
 #endif  // REGEN_H_
diff --git a/src/regen_dump.cc b/src/regen_dump.cc
index 13ab8be..5ee0159 100644
--- a/src/regen_dump.cc
+++ b/src/regen_dump.cc
@@ -29,12 +29,12 @@
 #include "log.h"
 #include "strutil.h"
 
-vector<string> LoadVecString(FILE* fp) {
+vector<std::string> LoadVecString(FILE* fp) {
   int count = LoadInt(fp);
   if (count < 0) {
     ERROR("Incomplete stamp file");
   }
-  vector<string> ret(count);
+  std::vector<std::string> ret(count);
   for (int i = 0; i < count; i++) {
     if (!LoadString(fp, &ret[i])) {
       ERROR("Incomplete stamp file");
diff --git a/src/rule.cc b/src/rule.cc
index 867a7e3..07116d2 100644
--- a/src/rule.cc
+++ b/src/rule.cc
@@ -47,7 +47,7 @@
   // First, separate command. At this point separator_pos should point to ';'
   // unless null.
   StringPiece prereq_string = line;
-  if (separator_pos != string::npos &&
+  if (separator_pos != std::string::npos &&
       rule_stmt->sep != RuleStmt::SEP_SEMICOLON) {
     CHECK(line[separator_pos] == ';');
     // TODO: Maybe better to avoid Intern here?
@@ -56,7 +56,7 @@
     prereq_string = line.substr(0, separator_pos);
   }
 
-  if ((separator_pos = prereq_string.find(':')) == string::npos) {
+  if ((separator_pos = prereq_string.find(':')) == std::string::npos) {
     // Simple prerequisites
     ParseInputs(prereq_string);
     return;
@@ -99,8 +99,8 @@
   ParseInputs(prereq_patterns);
 }
 
-string Rule::DebugString() const {
-  vector<string> v;
+std::string Rule::DebugString() const {
+  std::vector<std::string> v;
   v.push_back(StringPrintf("outputs=[%s]", JoinSymbols(outputs, ",").c_str()));
   v.push_back(StringPrintf("inputs=[%s]", JoinSymbols(inputs, ",").c_str()));
   if (!order_only_inputs.empty()) {
diff --git a/src/rule.h b/src/rule.h
index 237eb02..bbf5d45 100644
--- a/src/rule.h
+++ b/src/rule.h
@@ -25,8 +25,6 @@
 #include "string_piece.h"
 #include "symtab.h"
 
-using namespace std;
-
 class Value;
 
 class Rule {
@@ -35,7 +33,7 @@
 
   Loc cmd_loc() const { return Loc(loc.filename, cmd_lineno); }
 
-  string DebugString() const;
+  std::string DebugString() const;
 
   void ParseInputs(const StringPiece& inputs_string);
 
@@ -44,22 +42,22 @@
                           const RuleStmt* rule_stmt);
 
   static bool IsPatternRule(const StringPiece& target_string) {
-    return target_string.find('%') != string::npos;
+    return target_string.find('%') != std::string::npos;
   }
 
-  vector<Symbol> outputs;
-  vector<Symbol> inputs;
-  vector<Symbol> order_only_inputs;
-  vector<Symbol> output_patterns;
-  vector<Symbol> validations;
+  std::vector<Symbol> outputs;
+  std::vector<Symbol> inputs;
+  std::vector<Symbol> order_only_inputs;
+  std::vector<Symbol> output_patterns;
+  std::vector<Symbol> validations;
   bool is_double_colon;
   bool is_suffix_rule;
-  vector<Value*> cmds;
+  std::vector<Value*> cmds;
   Loc loc;
   int cmd_lineno;
 
  private:
-  void Error(const string& msg) { ERROR_LOC(loc, "%s", msg.c_str()); }
+  void Error(const std::string& msg) { ERROR_LOC(loc, "%s", msg.c_str()); }
 };
 
 #endif  // RULE_H_
diff --git a/src/stats.cc b/src/stats.cc
index be03774..6dccf7d 100644
--- a/src/stats.cc
+++ b/src/stats.cc
@@ -28,31 +28,31 @@
 
 namespace {
 
-mutex g_mu;
-vector<Stats*>* g_stats;
+std::mutex g_mu;
+std::vector<Stats*>* g_stats;
 
 }  // namespace
 
 Stats::Stats(const char* name) : name_(name), elapsed_(0), cnt_(0) {
-  unique_lock<mutex> lock(g_mu);
+  std::unique_lock<std::mutex> lock(g_mu);
   if (g_stats == NULL)
-    g_stats = new vector<Stats*>;
+    g_stats = new std::vector<Stats*>;
   g_stats->push_back(this);
 }
 
 void Stats::DumpTop() const {
-  unique_lock<mutex> lock(mu_);
+  std::unique_lock<std::mutex> lock(mu_);
   if (detailed_.size() > 0) {
-    vector<pair<string, StatsDetails>> details(detailed_.begin(),
-                                               detailed_.end());
+    std::vector<std::pair<std::string, StatsDetails>> details(detailed_.begin(),
+                                                              detailed_.end());
     sort(details.begin(), details.end(),
-         [](const pair<string, StatsDetails> a,
-            const pair<string, StatsDetails> b) -> bool {
+         [](const std::pair<std::string, StatsDetails> a,
+            const std::pair<std::string, StatsDetails> b) -> bool {
            return a.second.elapsed_ > b.second.elapsed_;
          });
 
     // Only print the top 10
-    details.resize(min(details.size(), static_cast<size_t>(10)));
+    details.resize(std::min(details.size(), static_cast<size_t>(10)));
 
     if (!interesting_.empty()) {
       // No need to print anything out twice
@@ -73,8 +73,8 @@
 
     int max_cnt_len = 1;
     for (auto& [name, detail] : details) {
-      max_cnt_len =
-          max(max_cnt_len, static_cast<int>(to_string(detail.cnt_).length()));
+      max_cnt_len = std::max(
+          max_cnt_len, static_cast<int>(std::to_string(detail.cnt_).length()));
     }
 
     for (auto& [name, detail] : details) {
@@ -84,8 +84,8 @@
   }
 }
 
-string Stats::String() const {
-  unique_lock<mutex> lock(mu_);
+std::string Stats::String() const {
+  std::unique_lock<std::mutex> lock(mu_);
   if (!detailed_.empty())
     return StringPrintf("%s: %f / %d (%d unique)", name_, elapsed_, cnt_,
                         detailed_.size());
@@ -94,25 +94,25 @@
 
 double Stats::Start() {
   double start = GetTime();
-  unique_lock<mutex> lock(mu_);
+  std::unique_lock<std::mutex> lock(mu_);
   cnt_++;
   return start;
 }
 
 double Stats::End(double start, const char* msg) {
   double e = GetTime() - start;
-  unique_lock<mutex> lock(mu_);
+  std::unique_lock<std::mutex> lock(mu_);
   elapsed_ += e;
   if (msg != 0) {
-    StatsDetails& details = detailed_[string(msg)];
+    StatsDetails& details = detailed_[std::string(msg)];
     details.elapsed_ += e;
     details.cnt_++;
   }
   return e;
 }
 
-void Stats::MarkInteresting(const string& msg) {
-  unique_lock<mutex> lock(mu_);
+void Stats::MarkInteresting(const std::string& msg) {
+  std::unique_lock<std::mutex> lock(mu_);
   interesting_.emplace(msg);
 }
 
diff --git a/src/stats.h b/src/stats.h
index 4501353..2c311f0 100644
--- a/src/stats.h
+++ b/src/stats.h
@@ -20,8 +20,6 @@
 #include <unordered_map>
 #include <unordered_set>
 
-using namespace std;
-
 struct StatsDetails {
   int cnt_ = 0;
   double elapsed_ = 0;
@@ -32,9 +30,9 @@
   explicit Stats(const char* name);
 
   void DumpTop() const;
-  string String() const;
+  std::string String() const;
 
-  void MarkInteresting(const string& msg);
+  void MarkInteresting(const std::string& msg);
 
  private:
   double Start();
@@ -45,9 +43,9 @@
   const char* name_;
   double elapsed_;
   int cnt_;
-  mutable mutex mu_;
-  unordered_map<string, StatsDetails> detailed_;
-  unordered_set<string> interesting_;
+  mutable std::mutex mu_;
+  std::unordered_map<std::string, StatsDetails> detailed_;
+  std::unordered_set<std::string> interesting_;
 };
 
 class ScopedStatsRecorder {
diff --git a/src/stmt.cc b/src/stmt.cc
index 7315dc1..bdc3406 100644
--- a/src/stmt.cc
+++ b/src/stmt.cc
@@ -30,13 +30,13 @@
   EvalStatement(ev);
 }
 
-string RuleStmt::DebugString() const {
+std::string RuleStmt::DebugString() const {
   return StringPrintf("RuleStmt(lhs=%s sep=%d rhs=%s loc=%s:%d)",
                       Value::DebugString(lhs).c_str(), sep,
                       Value::DebugString(rhs).c_str(), LOCF(loc()));
 }
 
-string AssignStmt::DebugString() const {
+std::string AssignStmt::DebugString() const {
   const char* opstr = "???";
   switch (op) {
     case AssignOp::EQ:
@@ -73,7 +73,7 @@
 
 Symbol AssignStmt::GetLhsSymbol(Evaluator* ev) const {
   if (!lhs->IsLiteral()) {
-    string buf;
+    std::string buf;
     lhs->Eval(ev, &buf);
     return Intern(buf);
   }
@@ -84,12 +84,12 @@
   return lhs_sym_cache_;
 }
 
-string CommandStmt::DebugString() const {
+std::string CommandStmt::DebugString() const {
   return StringPrintf("CommandStmt(%s, loc=%s:%d)",
                       Value::DebugString(expr).c_str(), LOCF(loc()));
 }
 
-string IfStmt::DebugString() const {
+std::string IfStmt::DebugString() const {
   const char* opstr = "???";
   switch (op) {
     case CondOp::IFEQ:
@@ -111,17 +111,17 @@
                       false_stmts.size(), LOCF(loc()));
 }
 
-string IncludeStmt::DebugString() const {
+std::string IncludeStmt::DebugString() const {
   return StringPrintf("IncludeStmt(%s, loc=%s:%d)",
                       Value::DebugString(expr).c_str(), LOCF(loc()));
 }
 
-string ExportStmt::DebugString() const {
+std::string ExportStmt::DebugString() const {
   return StringPrintf("ExportStmt(%s, %d, loc=%s:%d)",
                       Value::DebugString(expr).c_str(), is_export, LOCF(loc()));
 }
 
-string ParseErrorStmt::DebugString() const {
+std::string ParseErrorStmt::DebugString() const {
   return StringPrintf("ParseErrorStmt(%s, loc=%s:%d)", msg.c_str(),
                       LOCF(loc()));
 }
diff --git a/src/stmt.h b/src/stmt.h
index d0ef79b..1e96abc 100644
--- a/src/stmt.h
+++ b/src/stmt.h
@@ -22,8 +22,6 @@
 #include "string_piece.h"
 #include "symtab.h"
 
-using namespace std;
-
 class Evaluator;
 class Value;
 
@@ -58,7 +56,7 @@
   void Eval(Evaluator*) const;
   virtual void EvalStatement(Evaluator* ev) const = 0;
 
-  virtual string DebugString() const = 0;
+  virtual std::string DebugString() const = 0;
 
  protected:
   Stmt();
@@ -84,7 +82,7 @@
 
   virtual void EvalStatement(Evaluator* ev) const;
 
-  virtual string DebugString() const;
+  virtual std::string DebugString() const;
 };
 
 struct AssignStmt : public Stmt {
@@ -100,7 +98,7 @@
 
   virtual void EvalStatement(Evaluator* ev) const;
 
-  virtual string DebugString() const;
+  virtual std::string DebugString() const;
 
   Symbol GetLhsSymbol(Evaluator* ev) const;
 
@@ -116,21 +114,21 @@
 
   virtual void EvalStatement(Evaluator* ev) const;
 
-  virtual string DebugString() const;
+  virtual std::string DebugString() const;
 };
 
 struct IfStmt : public Stmt {
   CondOp op;
   Value* lhs;
   Value* rhs;
-  vector<Stmt*> true_stmts;
-  vector<Stmt*> false_stmts;
+  std::vector<Stmt*> true_stmts;
+  std::vector<Stmt*> false_stmts;
 
   virtual ~IfStmt();
 
   virtual void EvalStatement(Evaluator* ev) const;
 
-  virtual string DebugString() const;
+  virtual std::string DebugString() const;
 };
 
 struct IncludeStmt : public Stmt {
@@ -141,7 +139,7 @@
 
   virtual void EvalStatement(Evaluator* ev) const;
 
-  virtual string DebugString() const;
+  virtual std::string DebugString() const;
 };
 
 struct ExportStmt : public Stmt {
@@ -152,17 +150,17 @@
 
   virtual void EvalStatement(Evaluator* ev) const;
 
-  virtual string DebugString() const;
+  virtual std::string DebugString() const;
 };
 
 struct ParseErrorStmt : public Stmt {
-  string msg;
+  std::string msg;
 
   virtual ~ParseErrorStmt();
 
   virtual void EvalStatement(Evaluator* ev) const;
 
-  virtual string DebugString() const;
+  virtual std::string DebugString() const;
 };
 
 #endif  // STMT_H_
diff --git a/src/string_piece_test.cc b/src/string_piece_test.cc
index 0434cbe..275615f 100644
--- a/src/string_piece_test.cc
+++ b/src/string_piece_test.cc
@@ -20,10 +20,8 @@
 
 #include <unordered_set>
 
-using namespace std;
-
 int main() {
-  unordered_set<StringPiece> sps;
+  std::unordered_set<StringPiece> sps;
   sps.insert(StringPiece("foo"));
   sps.insert(StringPiece("foo"));
   sps.insert(StringPiece("bar"));
diff --git a/src/stringprintf.cc b/src/stringprintf.cc
index b0d4b4a..c16ca18 100644
--- a/src/stringprintf.cc
+++ b/src/stringprintf.cc
@@ -19,8 +19,8 @@
 #include <assert.h>
 #include <stdarg.h>
 
-string StringPrintf(const char* format, ...) {
-  string str;
+std::string StringPrintf(const char* format, ...) {
+  std::string str;
   str.resize(128);
   for (int i = 0; i < 2; i++) {
     va_list args;
diff --git a/src/stringprintf.h b/src/stringprintf.h
index 8b67e6c..d7e10a9 100644
--- a/src/stringprintf.h
+++ b/src/stringprintf.h
@@ -17,8 +17,6 @@
 
 #include <string>
 
-using namespace std;
-
-string StringPrintf(const char* fmt, ...);
+std::string StringPrintf(const char* fmt, ...);
 
 #endif  // STRINGPRINTF_H_
diff --git a/src/strutil.cc b/src/strutil.cc
index 4546265..5d89241 100644
--- a/src/strutil.cc
+++ b/src/strutil.cc
@@ -76,12 +76,12 @@
   return iter;
 }
 
-void WordScanner::Split(vector<StringPiece>* o) {
+void WordScanner::Split(std::vector<StringPiece>* o) {
   for (StringPiece t : *this)
     o->push_back(t);
 }
 
-WordWriter::WordWriter(string* o) : out_(o), needs_space_(false) {}
+WordWriter::WordWriter(std::string* o) : out_(o), needs_space_(false) {}
 
 void WordWriter::MaybeAddWhitespace() {
   if (needs_space_) {
@@ -104,7 +104,7 @@
   const_cast<char*>(s_.data())[s_.size()] = c_;
 }
 
-void AppendString(StringPiece str, string* out) {
+void AppendString(StringPiece str, std::string* out) {
   out->append(str.begin(), str.end());
 }
 
@@ -120,7 +120,7 @@
 
 bool HasWord(StringPiece str, StringPiece w) {
   size_t found = str.find(w);
-  if (found == string::npos)
+  if (found == std::string::npos)
     return false;
   if (found != 0 && !isSpace(str[found - 1]))
     return false;
@@ -147,7 +147,7 @@
 Pattern::Pattern(StringPiece pat) : pat_(pat), percent_index_(pat.find('%')) {}
 
 bool Pattern::Match(StringPiece str) const {
-  if (percent_index_ == string::npos)
+  if (percent_index_ == std::string::npos)
     return str == pat_;
   return MatchImpl(str);
 }
@@ -165,8 +165,8 @@
 
 void Pattern::AppendSubst(StringPiece str,
                           StringPiece subst,
-                          string* out) const {
-  if (percent_index_ == string::npos) {
+                          std::string* out) const {
+  if (percent_index_ == std::string::npos) {
     if (str == pat_) {
       AppendString(subst, out);
       return;
@@ -178,7 +178,7 @@
 
   if (MatchImpl(str)) {
     size_t subst_percent_index = subst.find('%');
-    if (subst_percent_index == string::npos) {
+    if (subst_percent_index == std::string::npos) {
       AppendString(subst, out);
       return;
     } else {
@@ -194,8 +194,9 @@
 
 void Pattern::AppendSubstRef(StringPiece str,
                              StringPiece subst,
-                             string* out) const {
-  if (percent_index_ != string::npos && subst.find('%') != string::npos) {
+                             std::string* out) const {
+  if (percent_index_ != std::string::npos &&
+      subst.find('%') != std::string::npos) {
     AppendSubst(str, subst, out);
     return;
   }
@@ -204,12 +205,12 @@
   out->append(subst.begin(), subst.end());
 }
 
-string NoLineBreak(const string& s) {
+std::string NoLineBreak(const std::string& s) {
   size_t index = s.find('\n');
-  if (index == string::npos)
+  if (index == std::string::npos)
     return s;
-  string r = s;
-  while (index != string::npos) {
+  std::string r = s;
+  while (index != std::string::npos) {
     r = r.substr(0, index) + "\\n" + r.substr(index + 1);
     index = r.find('\n', index + 2);
   }
@@ -251,7 +252,7 @@
 
 StringPiece Dirname(StringPiece s) {
   size_t found = s.rfind('/');
-  if (found == string::npos)
+  if (found == std::string::npos)
     return StringPiece(".");
   if (found == 0)
     return StringPiece("");
@@ -260,14 +261,14 @@
 
 StringPiece Basename(StringPiece s) {
   size_t found = s.rfind('/');
-  if (found == string::npos || found == 0)
+  if (found == std::string::npos || found == 0)
     return s;
   return s.substr(found + 1);
 }
 
 StringPiece GetExt(StringPiece s) {
   size_t found = s.rfind('.');
-  if (found == string::npos)
+  if (found == std::string::npos)
     return StringPiece("");
   return s.substr(found);
 }
@@ -275,13 +276,13 @@
 StringPiece StripExt(StringPiece s) {
   size_t slash_index = s.rfind('/');
   size_t found = s.rfind('.');
-  if (found == string::npos ||
-      (slash_index != string::npos && found < slash_index))
+  if (found == std::string::npos ||
+      (slash_index != std::string::npos && found < slash_index))
     return s;
   return s.substr(0, found);
 }
 
-void NormalizePath(string* o) {
+void NormalizePath(std::string* o) {
   if (o->empty())
     return;
   size_t start_index = 0;
@@ -308,7 +309,7 @@
         size_t orig_j = j;
         j -= 4;
         j = o->rfind('/', j);
-        if (j == string::npos) {
+        if (j == std::string::npos) {
           j = start_index;
         } else {
           j++;
@@ -332,7 +333,7 @@
   o->resize(j);
 }
 
-void AbsPath(StringPiece s, string* o) {
+void AbsPath(StringPiece s, std::string* o) {
   if (s.get(0) == '/') {
     o->clear();
   } else {
@@ -353,7 +354,7 @@
 template <typename Cond>
 size_t FindOutsideParenImpl(StringPiece s, Cond cond) {
   bool prev_backslash = false;
-  stack<char> paren_stack;
+  std::stack<char> paren_stack;
   for (size_t i = 0; i < s.size(); i++) {
     char c = s[i];
     if (cond(c) && paren_stack.empty() && !prev_backslash) {
@@ -376,7 +377,7 @@
     }
     prev_backslash = c == '\\' && !prev_backslash;
   }
-  return string::npos;
+  return std::string::npos;
 }
 
 size_t FindOutsideParen(StringPiece s, char c) {
@@ -429,7 +430,7 @@
   return s;
 }
 
-void FormatForCommandSubstitution(string* s) {
+void FormatForCommandSubstitution(std::string* s) {
   while ((*s)[s->size() - 1] == '\n')
     s->pop_back();
   for (size_t i = 0; i < s->size(); i++) {
@@ -438,8 +439,8 @@
   }
 }
 
-string SortWordsInString(StringPiece s) {
-  vector<string> toks;
+std::string SortWordsInString(StringPiece s) {
+  std::vector<std::string> toks;
   for (StringPiece tok : WordScanner(s)) {
     toks.push_back(tok.as_string());
   }
@@ -447,8 +448,8 @@
   return JoinStrings(toks, " ");
 }
 
-string ConcatDir(StringPiece b, StringPiece n) {
-  string r;
+std::string ConcatDir(StringPiece b, StringPiece n) {
+  std::string r;
   if (!b.empty() && (n.empty() || n[0] != '/')) {
     b.AppendToString(&r);
     r += '/';
@@ -458,9 +459,9 @@
   return r;
 }
 
-string EchoEscape(const string& str) {
+std::string EchoEscape(const std::string& str) {
   const char* in = str.c_str();
-  string buf;
+  std::string buf;
   for (; *in; in++) {
     switch (*in) {
       case '\\':
@@ -479,14 +480,14 @@
   return buf;
 }
 
-void EscapeShell(string* s) {
+void EscapeShell(std::string* s) {
   static const char delimiters[] = "\"$\\`";
   size_t prev = 0;
   size_t i = SkipUntil(s->c_str(), s->size(), delimiters);
   if (i == s->size())
     return;
 
-  string r;
+  std::string r;
   for (; i < s->size();) {
     StringPiece(*s).substr(prev, i - prev).AppendToString(&r);
     char c = (*s)[i];
diff --git a/src/strutil.h b/src/strutil.h
index d573b79..c5b961f 100644
--- a/src/strutil.h
+++ b/src/strutil.h
@@ -20,8 +20,6 @@
 
 #include "string_piece.h"
 
-using namespace std;
-
 class WordScanner {
  public:
   struct Iterator {
@@ -41,7 +39,7 @@
   Iterator begin() const;
   Iterator end() const;
 
-  void Split(vector<StringPiece>* o);
+  void Split(std::vector<StringPiece>* o);
 
  private:
   StringPiece in_;
@@ -49,12 +47,12 @@
 
 class WordWriter {
  public:
-  explicit WordWriter(string* o);
+  explicit WordWriter(std::string* o);
   void MaybeAddWhitespace();
   void Write(StringPiece s);
 
  private:
-  string* out_;
+  std::string* out_;
   bool needs_space_;
 };
 
@@ -70,8 +68,8 @@
 };
 
 template <class String>
-inline string JoinStrings(vector<String> v, const char* sep) {
-  string r;
+inline std::string JoinStrings(std::vector<String> v, const char* sep) {
+  std::string r;
   for (StringPiece s : v) {
     if (!r.empty()) {
       r += sep;
@@ -81,7 +79,7 @@
   return r;
 }
 
-void AppendString(StringPiece str, string* out);
+void AppendString(StringPiece str, std::string* out);
 
 bool HasPrefix(StringPiece str, StringPiece prefix);
 
@@ -101,9 +99,11 @@
 
   StringPiece Stem(StringPiece str) const;
 
-  void AppendSubst(StringPiece str, StringPiece subst, string* out) const;
+  void AppendSubst(StringPiece str, StringPiece subst, std::string* out) const;
 
-  void AppendSubstRef(StringPiece str, StringPiece subst, string* out) const;
+  void AppendSubstRef(StringPiece str,
+                      StringPiece subst,
+                      std::string* out) const;
 
  private:
   bool MatchImpl(StringPiece str) const;
@@ -112,7 +112,7 @@
   size_t percent_index_;
 };
 
-string NoLineBreak(const string& s);
+std::string NoLineBreak(const std::string& s);
 
 StringPiece TrimLeftSpace(StringPiece s);
 StringPiece TrimRightSpace(StringPiece s);
@@ -122,8 +122,8 @@
 StringPiece Basename(StringPiece s);
 StringPiece GetExt(StringPiece s);
 StringPiece StripExt(StringPiece s);
-void NormalizePath(string* o);
-void AbsPath(StringPiece s, string* o);
+void NormalizePath(std::string* o);
+void AbsPath(StringPiece s, std::string* o);
 
 size_t FindOutsideParen(StringPiece s, char c);
 size_t FindTwoOutsideParen(StringPiece s, char c1, char c2);
@@ -136,15 +136,15 @@
 // From http://www.gnu.org/software/make/manual/make.html#Features
 StringPiece TrimLeadingCurdir(StringPiece s);
 
-void FormatForCommandSubstitution(string* s);
+void FormatForCommandSubstitution(std::string* s);
 
-string SortWordsInString(StringPiece s);
+std::string SortWordsInString(StringPiece s);
 
-string ConcatDir(StringPiece b, StringPiece n);
+std::string ConcatDir(StringPiece b, StringPiece n);
 
-string EchoEscape(const string& str);
+std::string EchoEscape(const std::string& str);
 
-void EscapeShell(string* s);
+void EscapeShell(std::string* s);
 
 bool IsInteger(StringPiece s);
 
diff --git a/src/strutil_bench.cc b/src/strutil_bench.cc
index d3b2e6c..f49bf7a 100644
--- a/src/strutil_bench.cc
+++ b/src/strutil_bench.cc
@@ -22,11 +22,9 @@
 #include "strutil.h"
 #include "timeutil.h"
 
-using namespace std;
-
 int main() {
   g_flags.enable_stat_logs = true;
-  string s;
+  std::string s;
   while (s.size() < 400000) {
     if (!s.empty())
       s += ' ';
@@ -36,7 +34,7 @@
   ScopedTimeReporter tr("WordScanner");
   static const int N = 1000;
   for (int i = 0; i < N; i++) {
-    vector<StringPiece> toks;
+    std::vector<StringPiece> toks;
     WordScanner(s).Split(&toks);
   }
 }
diff --git a/src/strutil_test.cc b/src/strutil_test.cc
index d95d351..1209202 100644
--- a/src/strutil_test.cc
+++ b/src/strutil_test.cc
@@ -26,12 +26,10 @@
 #include "string_piece.h"
 #include "testutil.h"
 
-using namespace std;
-
 namespace {
 
 void TestWordScanner() {
-  vector<StringPiece> ss;
+  std::vector<StringPiece> ss;
   for (StringPiece tok : WordScanner("foo bar baz hogeeeeeeeeeeeeeeee")) {
     ss.push_back(tok);
   }
@@ -70,8 +68,8 @@
   ASSERT_EQ(TrimSuffix("bar", "bbar"), "bar");
 }
 
-string SubstPattern(StringPiece str, StringPiece pat, StringPiece subst) {
-  string r;
+std::string SubstPattern(StringPiece str, StringPiece pat, StringPiece subst) {
+  std::string r;
   Pattern(pat).AppendSubst(str, subst, &r);
   return r;
 }
@@ -104,7 +102,7 @@
   assert(!HasWord("foo bar baz", "fo"));
 }
 
-static string NormalizePath(string s) {
+static std::string NormalizePath(std::string s) {
   ::NormalizePath(&s);
   return s;
 }
@@ -132,7 +130,7 @@
   ASSERT_EQ(NormalizePath("./../../a/b"), "../../a/b");
 }
 
-string EscapeShell(string s) {
+std::string EscapeShell(std::string s) {
   ::EscapeShell(&s);
   return s;
 }
@@ -184,7 +182,7 @@
 }
 
 void TestWordScannerInvalidAccess() {
-  vector<StringPiece> ss;
+  std::vector<StringPiece> ss;
   for (StringPiece tok : WordScanner(CreateProtectedString("0123 456789"))) {
     ss.push_back(tok);
   }
diff --git a/src/symtab.cc b/src/symtab.cc
index 69895f7..9c17495 100644
--- a/src/symtab.cc
+++ b/src/symtab.cc
@@ -35,8 +35,8 @@
   Var* gv;
 };
 
-vector<string*>* g_symbols;
-static vector<SymbolData> g_symbol_data;
+std::vector<std::string*>* g_symbols;
+static std::vector<SymbolData> g_symbol_data;
 
 Symbol kEmptySym;
 Symbol kShellSym;
@@ -143,7 +143,7 @@
 
   ~Symtab() {
     LOG_STAT("%zu symbols", symbols_.size());
-    for (string* s : symbols_)
+    for (std::string* s : symbols_)
       delete s;
   }
 
@@ -152,7 +152,7 @@
     if (found != symtab_.end()) {
       return found->second;
     }
-    symbols_.push_back(new string(s.data(), s.size()));
+    symbols_.push_back(new std::string(s.data(), s.size()));
     Symbol sym = Symbol(symtab_.size());
     bool ok = symtab_.emplace(*symbols_.back(), sym).second;
     CHECK(ok);
@@ -171,8 +171,9 @@
     return InternImpl(s);
   }
 
-  vector<StringPiece> GetSymbolNames(std::function<bool(Var*)> const& filter) {
-    vector<StringPiece> result;
+  std::vector<StringPiece> GetSymbolNames(
+      std::function<bool(Var*)> const& filter) {
+    std::vector<StringPiece> result;
     for (auto entry : symtab_) {
       Var* var = entry.second.PeekGlobalVar();
       // The symbol table contains all interned strings, not just variables
@@ -188,8 +189,8 @@
   }
 
  private:
-  unordered_map<StringPiece, Symbol> symtab_;
-  vector<string*> symbols_;
+  std::unordered_map<StringPiece, Symbol> symtab_;
+  std::vector<std::string*> symbols_;
 #ifdef ENABLE_TID_CHECK
   pthread_t tid_;
 #endif
@@ -201,8 +202,8 @@
   return g_symtab.Intern(s);
 }
 
-string JoinSymbols(const vector<Symbol>& syms, const char* sep) {
-  vector<string> strs;
+std::string JoinSymbols(const std::vector<Symbol>& syms, const char* sep) {
+  std::vector<std::string> strs;
   strs.reserve(syms.size());
   for (Symbol s : syms) {
     strs.push_back(s.str());
@@ -210,6 +211,7 @@
   return JoinStrings(strs, sep);
 }
 
-vector<StringPiece> GetSymbolNames(std::function<bool(Var*)> const& filter) {
+std::vector<StringPiece> GetSymbolNames(
+    std::function<bool(Var*)> const& filter) {
   return g_symtab.GetSymbolNames(filter);
 }
diff --git a/src/symtab.h b/src/symtab.h
index f3524ca..137b8ef 100644
--- a/src/symtab.h
+++ b/src/symtab.h
@@ -22,9 +22,7 @@
 
 #include "string_piece.h"
 
-using namespace std;
-
-extern vector<string*>* g_symbols;
+extern std::vector<std::string*>* g_symbols;
 
 class Symtab;
 class Var;
@@ -33,7 +31,7 @@
  public:
   explicit Symbol() : v_(-1) {}
 
-  const string& str() const { return *((*g_symbols)[v_]); }
+  const std::string& str() const { return *((*g_symbols)[v_]); }
 
   const char* c_str() const { return str().c_str(); }
 
@@ -42,7 +40,7 @@
   int val() const { return v_; }
 
   char get(size_t i) const {
-    const string& s = str();
+    const std::string& s = str();
     if (i >= s.size())
       return 0;
     return s[i];
@@ -223,9 +221,10 @@
 
 Symbol Intern(StringPiece s);
 
-string JoinSymbols(const vector<Symbol>& syms, const char* sep);
+std::string JoinSymbols(const std::vector<Symbol>& syms, const char* sep);
 
 // Get all symbol names for which filter returns true.
-vector<StringPiece> GetSymbolNames(std::function<bool(Var*)> const& filter);
+std::vector<StringPiece> GetSymbolNames(
+    std::function<bool(Var*)> const& filter);
 
 #endif  // SYMTAB_H_
diff --git a/src/var.cc b/src/var.cc
index e51aa6b..93b340a 100644
--- a/src/var.cc
+++ b/src/var.cc
@@ -21,7 +21,7 @@
 #include "log.h"
 #include "strutil.h"
 
-unordered_map<const Var*, string> Var::diagnostic_messages_;
+std::unordered_map<const Var*, std::string> Var::diagnostic_messages_;
 
 const char* GetOriginStr(VarOrigin origin) {
   switch (origin) {
@@ -90,8 +90,8 @@
   return it == diagnostic_messages_.end() ? "" : it->second.c_str();
 }
 
-const string& Var::DeprecatedMessage() const {
-  static const string empty_string;
+const std::string& Var::DeprecatedMessage() const {
+  static const std::string empty_string;
   auto it = diagnostic_messages_.find(this);
   return it == diagnostic_messages_.end() ? empty_string : it->second;
 }
@@ -107,7 +107,7 @@
 SimpleVar::SimpleVar(VarOrigin origin, Frame* definition, Loc loc)
     : Var(origin, definition, loc) {}
 
-SimpleVar::SimpleVar(const string& v,
+SimpleVar::SimpleVar(const std::string& v,
                      VarOrigin origin,
                      Frame* definition,
                      Loc loc)
@@ -126,13 +126,13 @@
   return false;
 }
 
-void SimpleVar::Eval(Evaluator* ev, string* s) const {
+void SimpleVar::Eval(Evaluator* ev, std::string* s) const {
   ev->CheckStack();
   *s += v_;
 }
 
 void SimpleVar::AppendVar(Evaluator* ev, Value* v) {
-  string buf;
+  std::string buf;
   v->Eval(ev, &buf);
   v_.push_back(' ');
   v_ += buf;
@@ -143,7 +143,7 @@
   return v_;
 }
 
-string SimpleVar::DebugString() const {
+std::string SimpleVar::DebugString() const {
   return v_;
 }
 
@@ -158,7 +158,7 @@
   return v_->IsFunc(ev);
 }
 
-void RecursiveVar::Eval(Evaluator* ev, string* s) const {
+void RecursiveVar::Eval(Evaluator* ev, std::string* s) const {
   ev->CheckStack();
   v_->Eval(ev, s);
 }
@@ -186,7 +186,7 @@
   return orig_;
 }
 
-string RecursiveVar::DebugString() const {
+std::string RecursiveVar::DebugString() const {
   return Value::DebugString(v_);
 }
 
@@ -196,7 +196,7 @@
   return false;
 }
 
-void UndefinedVar::Eval(Evaluator*, string*) const {
+void UndefinedVar::Eval(Evaluator*, std::string*) const {
   // Nothing to do.
 }
 
@@ -204,7 +204,7 @@
   return StringPiece("");
 }
 
-string UndefinedVar::DebugString() const {
+std::string UndefinedVar::DebugString() const {
   return "*undefined*";
 }
 
@@ -218,7 +218,7 @@
   return false;
 }
 
-void VariableNamesVar::Eval(Evaluator* ev, string* s) const {
+void VariableNamesVar::Eval(Evaluator* ev, std::string* s) const {
   ConcatVariableNames(ev, s);
 }
 
@@ -226,9 +226,10 @@
   return name_;
 }
 
-void VariableNamesVar::ConcatVariableNames(Evaluator* ev, string* s) const {
+void VariableNamesVar::ConcatVariableNames(Evaluator* ev,
+                                           std::string* s) const {
   WordWriter ww(s);
-  vector<StringPiece>&& symbols = GetSymbolNames([=](Var* var) -> bool {
+  std::vector<StringPiece>&& symbols = GetSymbolNames([=](Var* var) -> bool {
     if (var->Obsolete()) {
       return false;
     }
@@ -244,7 +245,7 @@
   }
 }
 
-string VariableNamesVar::DebugString() const {
+std::string VariableNamesVar::DebugString() const {
   return "*VariableNamesVar*";
 }
 
@@ -269,7 +270,7 @@
   return false;
 }
 
-void ShellStatusVar::Eval(Evaluator* ev, string* s) const {
+void ShellStatusVar::Eval(Evaluator* ev, std::string* s) const {
   if (ev->IsEvaluatingCommand()) {
     ev->Error("Kati does not support using .SHELLSTATUS inside of a rule");
   }
@@ -289,7 +290,7 @@
   return std::to_string(shell_status_);
 }
 
-string ShellStatusVar::DebugString() const {
+std::string ShellStatusVar::DebugString() const {
   return "*ShellStatusVar*";
 }
 
diff --git a/src/var.h b/src/var.h
index 67b26f6..2186460 100644
--- a/src/var.h
+++ b/src/var.h
@@ -28,8 +28,6 @@
 #include "string_piece.h"
 #include "symtab.h"
 
-using namespace std;
-
 class Evaluator;
 class Value;
 
@@ -61,7 +59,7 @@
 
   virtual StringPiece String() const = 0;
 
-  virtual string DebugString() const = 0;
+  virtual std::string DebugString() const = 0;
 
   bool ReadOnly() const { return readonly_; }
   void SetReadOnly() { readonly_ = true; }
@@ -75,7 +73,7 @@
   bool SelfReferential() const { return self_referential_; }
   void SetSelfReferential() { self_referential_ = true; }
 
-  const string& DeprecatedMessage() const;
+  const std::string& DeprecatedMessage() const;
 
   // This variable was used (either written or read from)
   virtual void Used(Evaluator* ev, const Symbol& sym) const;
@@ -102,13 +100,13 @@
 
   const char* diagnostic_message_text() const;
 
-  static unordered_map<const Var*, string> diagnostic_messages_;
+  static std::unordered_map<const Var*, std::string> diagnostic_messages_;
 };
 
 class SimpleVar : public Var {
  public:
   explicit SimpleVar(VarOrigin origin, Frame* definition, Loc loc);
-  SimpleVar(const string& v, VarOrigin origin, Frame* definition, Loc loc);
+  SimpleVar(const std::string& v, VarOrigin origin, Frame* definition, Loc loc);
   SimpleVar(VarOrigin origin,
             Frame* definition,
             Loc loc,
@@ -119,15 +117,15 @@
 
   virtual bool IsFunc(Evaluator* ev) const override;
 
-  virtual void Eval(Evaluator* ev, string* s) const override;
+  virtual void Eval(Evaluator* ev, std::string* s) const override;
 
   virtual void AppendVar(Evaluator* ev, Value* v) override;
 
   virtual StringPiece String() const override;
 
-  virtual string DebugString() const override;
+  virtual std::string DebugString() const override;
 
-  string v_;
+  std::string v_;
 };
 
 class RecursiveVar : public Var {
@@ -142,13 +140,13 @@
 
   virtual bool IsFunc(Evaluator* ev) const override;
 
-  virtual void Eval(Evaluator* ev, string* s) const override;
+  virtual void Eval(Evaluator* ev, std::string* s) const override;
 
   virtual void AppendVar(Evaluator* ev, Value* v) override;
 
   virtual StringPiece String() const override;
 
-  virtual string DebugString() const override;
+  virtual std::string DebugString() const override;
 
   virtual void Used(Evaluator* ev, const Symbol& sym) const override;
 
@@ -165,11 +163,11 @@
 
   virtual bool IsFunc(Evaluator* ev) const override;
 
-  virtual void Eval(Evaluator* ev, string* s) const override;
+  virtual void Eval(Evaluator* ev, std::string* s) const override;
 
   virtual StringPiece String() const override;
 
-  virtual string DebugString() const override;
+  virtual std::string DebugString() const override;
 };
 
 // The built-in VARIABLES and KATI_SYMBOLS variables
@@ -182,17 +180,17 @@
 
   virtual bool IsFunc(Evaluator* ev) const override;
 
-  virtual void Eval(Evaluator* ev, string* s) const override;
+  virtual void Eval(Evaluator* ev, std::string* s) const override;
 
   virtual StringPiece String() const override;
 
-  virtual string DebugString() const override;
+  virtual std::string DebugString() const override;
 
  private:
   StringPiece name_;
   bool all_;
 
-  void ConcatVariableNames(Evaluator* ev, string* s) const;
+  void ConcatVariableNames(Evaluator* ev, std::string* s) const;
 };
 
 // The built-in .SHELLSTATUS variable
@@ -207,18 +205,18 @@
 
   virtual bool IsFunc(Evaluator* ev) const override;
 
-  virtual void Eval(Evaluator* ev, string* s) const override;
+  virtual void Eval(Evaluator* ev, std::string* s) const override;
 
   virtual StringPiece String() const override;
 
-  virtual string DebugString() const override;
+  virtual std::string DebugString() const override;
 
  private:
   static bool is_set_;
   static int shell_status_;
 };
 
-class Vars : public unordered_map<Symbol, Var*> {
+class Vars : public std::unordered_map<Symbol, Var*> {
  public:
   ~Vars();