fixed state hashing, implemented more arithmetic