ARIES-677 There were 3 places where services, references and beans were being "cleaned up" in the wrong order. This has been refactored to be in one place with the correct order.