Encode magic numbers at build time.
Check instance types with strings to handle possible reference issues.
Top level functions are generated.
Move `is_instance` and `should_wrap`.
Merge code paths for `_write_query` and `_send_query`.
Rename `cb` -> `callback` arg.
Rename `opts` -> `global_opts`.
Fix indentation.
Simplify getting length.