Partial rewrite of the callout code.

Now uses the callout_manager to handle interaction in a much more straightforward way than before.
Still needs a lot of internals rewritten, but it seems to be as functional as it was before.