Fix bug with removal of multiple service ids that refer to a common internal service module, to make sure the last removal is what removes the application dependencies when automatic_loading is true.