public static function createInstance(Application $sugarApp, $sugarUserId)
    {
        if (!is_null(self::$instance)) {
            if (self::$instance->getPath() !== $sugarApp->getPath()) {
                // We have an instance but with a different path
                throw new \RuntimeException('Unable to create another SugarCRM\EntryPoint from another path.');
            }
            self::$instance->getInstance();
            self::$instance->setCurrentUser($sugarUserId);
        } else {
            // Init in a variable for now in case an exception occurs
            $instance = new self($sugarApp, $sugarUserId);
            $instance->initSugar();
            // now that sugar in initialized without exceptions we can set the single instance.
            self::$instance = $instance;
        }
        return self::$instance;
    }