Most of the work for the srpush script. See TODO inside for more info.