Added basic state switching mechanics.