Major refactoring of service handling