Implement __mod, improve error reporting in bnerror().