Added collision and improved detection of states