This is where I use `toolz`, I'll tear this out before merger.  The replaced code above was behaving oddly for me.