public function flush()
    {
        try
        {
            //Writes all entities to the DB
            $this->writeEntities();

            //Write node labels
            $this->writeLabels();

            //Write indexes
            $this->writeIndexes();

            //Delete removed entities
            $this->removeEntities();

            //Clear entity lists
            $this->clearEntities();
        }
        catch(Exception $e)
        {
            //Flush failed, clear the queued up entities
            $this->clearEntities();

            //Throw the error back to the user
            throw $e;
        }
    }