Fixes the state comparison. Contributed by Aleksandras Nelkinas (Cinamonas)