Fixed State stack overflow bug