replaceNeeded: string->const string, fix exit codes