Remove MMDB_BROKEN_TYPE define
Use ip_version from metadata rather than depth
Reorder functions and defines

Put defines up top and reorder functions to more or less match calling order,
with utility-ish things at the bottom