Bug fixes in state machines. Added GUB state for expand phase as well. However not tested yet.