BUGFIX:
 - since I started with valgrind, I went all in and killed some more
off-by-ones. That took a while to get right, sadly.