Code tidy and added service discovery