<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def unget_used_services(self, bundle):
 """ Cleans up all service usages of the given bundle. :param bundle: Bundle to be cleaned up """

        # Pop used references
        try:
            imported_refs = list(self.__bundle_imports.pop(bundle))
        except KeyError:
            # Nothing to do
            return

        for svc_ref in imported_refs:
            # Remove usage marker
            svc_ref.unused_by(bundle)

            if svc_ref.is_prototype():
                # Get factory information and clean up the service from the
                # factory counter
                factory_counter = self.__factory_usage.pop(bundle)
                factory, svc_reg = self.__svc_factories[svc_ref]
                factory_counter.cleanup_service(factory, svc_reg)
            elif svc_ref.is_factory():
                # Factory service, release it the standard way
                self.__unget_service_from_factory(bundle, svc_ref)

        # Clean up local structures
        try:
            del self.__factory_usage[bundle]
        except KeyError:
            pass

        try:
            self.__bundle_imports.pop(bundle).clear()
        except KeyError:
            pass