Use Magazine for caching.

Implementing Magazine caught a fair bit of incorrect locking in the
tests.

Closes #121.