Ok, I've got something that should work more cleanly here -- will do a PR against this branch shortly.