All that work and then somehow transposing the A and B keys at the very end.

fixed!