Fix state switching bugs
0.1.6