CLOUDSTACK-6887: Code enhancement to ensure better cleanup