Fix a few libnative bugs

Details are in the commit messages, but this closes a few issues seen with `libnative` recently.