Bunch of fixes observed during hot standby testing, fixing memory leaks, and tidying API

WIP - FOR REVIEW ONLY.

just discovered one bug i can't seem to track down, where service_up does not recompute itself as true