Added nil check when performing delete.