Fix a couple pre-existing error handling bugs