Main state mach. working. so far. Half pass at cleaning out old code