On another point of detail - There is no requirement for a database to convert between Mode S Hex codes and US N-numbers. The Hex code is a straight encoding of the tail number.
I don't think it works for other states. e.g.
40041A is G-BUSK
40041B is G-BNWA
must be pretty fancy coding. I'm not totally convinced about the N-reg version:
52146651 = N66656
52146714 = N66666
52146757 = N66676
Different gaps in Mode S. Something doesn't quite chirp true...