private function removeEntities()
    {
        //Keep track of the relations you have already deleted, so you don't try to delete them twice
        $deletedRelations = array();

        //Begin the database batch
        $this->beginBatch();

        foreach($this->nodeEntitiesToRemove as $node)
        {

            //Get the primary key
            $meta = $this->getMeta($node);
            $id = $meta->getPrimaryKey()->getValue($node);

            if($id)
            {
                //Grab the node from the database
                $entity = $this->client->getNode($id);

                //Delete all the nodes relations
                $relationships = $entity->getRelationships();

                foreach ($relationships as $relationship)
                {
                    //Don't delete it if it's already been deleted in this batch!
                    if(!in_array($relationship->getId(), $deletedRelations))
                    {
                        $deletedRelations[] = $relationship->getId();
                        $relationship->delete();
                    }
                }

                //Delete index information
                $class = $meta->getName();
                $index = $this->getRepository($class)->getIndex();
                $index->remove($entity);

                //Delete the node
                $entity->delete();
            }
        }

        foreach($this->relationEntitiesToRemove as $relation)
        {
            //Get the primary key
            $meta = $this->getMeta($relation);
            $id = $meta->getPrimaryKey()->getValue($relation);

            //If the relation has an id, and hasn't been deleted already in this batch, delete it!
            if($id && !in_array($id, $deletedRelations))
            {
                //Grab everyman relationship
                $entity = $this->client->getRelationship($id);

                //Delete index information
                $class = $meta->getName();
                $index = $this->getRepository($class)->getIndex();
                $index->remove($entity);

                //Delete the entity
                $entity->delete();
            }
        }

        //Commit the database batch
        $this->commitBatch();
    }