Pull service stuff out to main() and misc changes.