Replaced switch-case and bit calculation with a table.
Reordered unpack selector sequence.