Completely replace SMS sending code.

...and tidy up some.