Use erlang:nif_error to make dialyzer happy

And mark some of the NIF functions