Add assertions

I haven't been able to test either of these assertions, but we
encountered both of these issues, and I believe they'd have helped us
track them down much faster.