clean up hostname handling, make service_name() static