Code cleanup, and use for a new service