Bug 831100 - use std::string. Extra reviews. r=ehsan,vladan.
Bug 831748 - refactor duplicated code. r=froydnj.