rewrite the code so now basis states are stored using bytes and all operations are done bitwise