State machines fix