misc: fixup some nasty bugs