Err. Yes. That's obviously wrong. Good catch. I'm not sure what happened there. 

In general I definitely intend to give this code a much more thorough set of testing and auditing before this PR is remotely ready to merge. I mostly just wanted to see if you were OK with the basic concept.