def init_plex():
        # plex.py
        Plex.configuration.defaults.authentication(
            os.environ.get('PLEXTOKEN')
        )

        # plex.activity.py
        path = os.path.join(Core.log.handlers[1].baseFilename, '..', '..', 'Plex Media Server.log')
        path = os.path.abspath(path)

        Activity['logging'].add_hint(path)

        # plex.metadata.py
        Metadata.configure(
            cache=CacheManager.get('metadata'),
            client=Plex.client
        )
    def initialize(cls):
        cls.thread = threading.Thread(target=cls.run, name="SyncManager")
        cls.lock = threading.Lock()

        cls.handlers = dict([(h.key, h(cls)) for h in HANDLERS])
        cls.statistics = SyncStatistics(cls)

        # Load/setup matcher cache
        Plex.configuration.defaults.cache(
            matcher=CacheManager.get('matcher', persistent=True)
        )

        # Bind activity events
        Activity.on('websocket.scanner.finished', cls.scanner_finished)

        EG['SyncManager.current'].set(lambda: cls.current)

        cls.initialized = True
        success = False

        try:
            success = handler.run(section=section, **kwargs)
        except CancelException, e:
            handler.update_status(False)

            log.info('Task "%s" was cancelled', key)
        except Exception, ex:
            handler.update_status(False)

            log.error('Exception raised in handler for %r: %s', key, ex, exc_info=True)

        log.debug(
            'Cache Statistics - len(matcher): %s, len(metadata): %s',
            len(CacheManager.get('matcher')),
            len(CacheManager.get('metadata'))
        )

        # Sync "matcher" cache (back to disk)
        CacheManager.get('matcher').sync()

        # Clear memory caches
        CacheManager.get('matcher').cache.clear()
        CacheManager.get('metadata').cache.clear()

        # Run garbage collection
        log.debug('[GC] Collected %d objects', gc.collect())
        log.debug('[GC] Count: %s', gc.get_count())
        log.debug('[GC] Garbage: %s', len(gc.garbage))