I was indexing bits in bytes backwards.