Fix a couple of bugs

Thanks to Kinnay for reporting these.