I understand that named elements of a tikzpicture cannot be referenced before they are defined; but I'm confused about how "long" a named element persists. It appears that once named, an element continues to exist, even in (subsequent) pictures that do not contain the element.
For example, the code
\draw[bluearrow](e)--(r);
generates the expected "undefined element" error if used prior to the definition of 'e' and 'r', but once I create a picture containing code that defines these elements, subsequent figures containing exactly the code above will no longer produce an error, and will instead draw the requested arrow, between the locations in that figure corresponding to the locations of 'e' and 'r' in the original figure in which they were defined:

What is the default scope of tikzpicture element names? Is there a way to control their scope? The (apparent) default behavior seems likely to produce hard to debug behavior in figures.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows}
\usetikzlibrary{petri}
\begin{document}
\tikzset{
bluearrow/.style={->, blue, fill=none,>=stealth', thick},
state/.style={circle,draw=black,inner sep=0pt,minimum size=7mm,label=center:$#1$,name=#1}}
\begin{center}
% This fails here ...
%\begin{tikzpicture}
%\draw[bluearrow](e)--(a);\draw[bluearrow](a)--(a^2);\draw[bluearrow](a^2)--(a^3);\draw[bluearrow](a^3)--(e);
%\end{tikzpicture}
\begin{tikzpicture}
\def\nodes{0/{e},1/{r},2/{r^2},3/{r^3}};\def\dim{4};
\foreach \n\lab in \nodes{
\node[state={\lab}]at({cos(90+\n*(360/\dim))},{sin(90+\n*(360/\dim))}){};}
\draw[bluearrow](e)--(r);\draw[bluearrow](r)--(r^2);\draw[bluearrow](r^2)--(r^3);\draw[bluearrow](r^3)--(e);
\end{tikzpicture}
\vspace{10 mm}
% ... but it works fine here.
\begin{tikzpicture}
\draw[bluearrow](e)--(r);\draw[bluearrow](r)--(r^2);\draw[bluearrow](r^2)--(r^3);\draw[bluearrow](r^3)--(e);
\end{tikzpicture}
\end{center}
\end{document}