I really don't like the nil checks here -- the fact that you see the need for them in test/development mode means that they diverge too far from how the system operates in production mode.