more bug fixes

There's still a heisenbug valueerror around line 256, but I can't repro
:(