Complete rewrite, added support for hex IDs and auth keys