Removed dead code and minimized states