fix crash + add state change thingy
merge