public function deletePreference( $name, $index = null )
    {
        $count = 0;

        foreach( $this->getPreferences() as $pref )
        {
            if( ( $pref->getName() == $name ) && ( ( $index === null ) || ( $pref->getIx() == $index ) ) )
            {
                $count++;
                $this->getPreferences()->removeElement( $pref );
                \D2EM::remove( $pref );
            }
        }

        return $count;
    }