Switched from the old ~"str" syntax to using .to_owned()

The `~"string"` syntax was removed, so this replaces all instances of it with `.to_owned()`.