Switch changed to rely on an atom instead of a ref

This should be marginally faster and avoid transaction retries
should they happen. I'm not familiar with criterium or other
libraries to validate the hypothesis that it is faster, so this
is just conjecture.