Use common code and constants from services.inc

to reduce code duplication