Fixed bug: new state should not depend only on OutputDecisionList, but also on existing state. Added the MainStruct, with currentportstate list to help keep track of ports