Fix a couple of obscure bugs.