Fixed a huge state bug I hadn't noticed. Made the included example a little bit more useful.