Index: protocol/pom.xml
===================================================================
--- protocol/pom.xml	(revision 21)
+++ protocol/pom.xml	(revision 22)
@@ -6,5 +6,5 @@
 	<groupId>geniusweb</groupId>
 	<artifactId>protocol</artifactId>
-	<version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
+	<version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
 	<packaging>jar</packaging>
 
@@ -17,5 +17,5 @@
 		<passwd>${env.ARTIFACTORY_PASS}</passwd>
 		<jackson-2-version>2.9.10</jackson-2-version>
-		<geniusweb.version>1.5.0</geniusweb.version>
+		<geniusweb.version>1.5.1</geniusweb.version>
 	</properties>
 
Index: protocol/src/main/java/geniusweb/protocol/session/mopac/MOPAC.java
===================================================================
--- protocol/src/main/java/geniusweb/protocol/session/mopac/MOPAC.java	(revision 21)
+++ protocol/src/main/java/geniusweb/protocol/session/mopac/MOPAC.java	(revision 22)
@@ -145,5 +145,5 @@
 			ProtocolToPartyConnFactory connectionfactory) {
 		try {
-			System.out.println("starting MOPAC");
+			//System.out.println("starting MOPAC");
 			// we're in Phase.INIT still
 			connect(connectionfactory);
@@ -314,5 +314,5 @@
 			final ProtocolToPartyConn partyconn, final Action action,
 			long now) {
-		System.out.println("received " + action);
+		//System.out.println("received " + action);
 		state = state.with(partyconn.getParty(), action, now);
 		checkEndPhase(System.currentTimeMillis());
@@ -341,4 +341,5 @@
 
 		state = state.nextPhase(now);
+
 		startPhase(now);
 	}
@@ -351,5 +352,5 @@
 	 */
 	private void broadcastNegotiators(Inform info) {
-		System.out.println("broadcasting " + info);
+		//System.out.println("broadcasting " + info);
 		for (PartyId party : state.getPhase().getPartyStates()
 				.getNegotiatingParties()) {
Index: protocol/src/main/java/geniusweb/protocol/session/mopac/MOPACState.java
===================================================================
--- protocol/src/main/java/geniusweb/protocol/session/mopac/MOPACState.java	(revision 21)
+++ protocol/src/main/java/geniusweb/protocol/session/mopac/MOPACState.java	(revision 22)
@@ -14,4 +14,5 @@
 import geniusweb.actions.PartyId;
 import geniusweb.inform.Agreements;
+import geniusweb.inform.OptIn;
 import geniusweb.progress.Progress;
 import geniusweb.progress.ProgressRounds;
@@ -22,4 +23,5 @@
 import geniusweb.protocol.session.SessionState;
 import geniusweb.protocol.session.mopac.phase.OfferPhase;
+import geniusweb.protocol.session.mopac.phase.OptInPhase;
 import geniusweb.protocol.session.mopac.phase.Phase;
 import geniusweb.protocol.session.saop.SAOPSettings;
@@ -127,8 +129,11 @@
 	/**
 	 * @param now current time ms since 1970
-	 * @return the max possible duration in ms of this phase. Maybe negative if
-	 *         ew are past deadline
+	 * @return the max possible duration in ms of the NEXT phase. Maybe 0 or
+	 *         negative if past deadline.
 	 */
 	private Long getAvailablePhaseTime(long now) {
+		// explicit check, to check also the round counts.
+		if (incrementProgress().isPastDeadline(now + Phase.PHASE_MINTIME))
+			return 0l;
 		return Math.min(progress.getTerminationTime().getTime() - now,
 				Phase.PHASE_MAXTIME);
@@ -196,11 +201,18 @@
 		Phase newphase = phase.next(now,
 				Math.min(remainingNegoTime, Phase.PHASE_MAXTIME));
-		Progress newprogress = progress;
-		if (newphase instanceof OfferPhase
-				&& progress instanceof ProgressRounds)
-			newprogress = ((ProgressRounds) progress).advance();
-
-		return new MOPACState(newphase, actions, connections, newprogress,
-				getSettings(), partyprofiles);
+
+		return new MOPACState(newphase, actions, connections,
+				incrementProgress(), getSettings(), partyprofiles);
+	}
+
+	/**
+	 * 
+	 * @return the next progress. Progress round advances if phase is
+	 *         {@link OptIn}.
+	 */
+	private Progress incrementProgress() {
+		if (progress instanceof ProgressRounds && phase instanceof OptInPhase)
+			return ((ProgressRounds) progress).advance();
+		return progress;
 	}
 
@@ -217,6 +229,9 @@
 	 */
 	public boolean isNewPhasePossible(long now) {
-		return phase.getPartyStates().getNegotiatingParties().size() >= 2
+		// System.out.println("phase=" + phase);
+		boolean a = phase.getPartyStates().getNegotiatingParties().size() >= 2
 				&& getAvailablePhaseTime(now) > Phase.PHASE_MINTIME;
+		// System.out.println("newstate possible:" + a);
+		return a;
 	}
 
Index: protocol/src/test/java/geniusweb/protocol/session/amop/AMOPSettingsTest.java
===================================================================
--- protocol/src/test/java/geniusweb/protocol/session/amop/AMOPSettingsTest.java	(revision 21)
+++ protocol/src/test/java/geniusweb/protocol/session/amop/AMOPSettingsTest.java	(revision 22)
@@ -97,4 +97,5 @@
 	}
 
+	@SuppressWarnings("unused")
 	@Test(expected = IllegalArgumentException.class)
 	public void constructorNoDeadlineTest() {
Index: protocol/src/test/java/geniusweb/protocol/session/amop/AMOPStateTest.java
===================================================================
--- protocol/src/test/java/geniusweb/protocol/session/amop/AMOPStateTest.java	(revision 21)
+++ protocol/src/test/java/geniusweb/protocol/session/amop/AMOPStateTest.java	(revision 22)
@@ -172,4 +172,5 @@
 	}
 
+	@SuppressWarnings("unused")
 	@Test
 	public void constructWithNullConnection() {
@@ -375,11 +376,12 @@
 	@Test
 	public void testCollectVotes() {
-		Votes vote1AB = new Votes(party1,
-				Arrays.asList(new Vote(party1, a, 2), new Vote(party1, b, 2)));
-		Votes vote2AB = new Votes(party2,
-				Arrays.asList(new Vote(party2, a, 2), new Vote(party2, b, 2)));
-		Votes vote3C = new Votes(party3, Arrays.asList(new Vote(party3, c, 2)));
-		Votes vote4AC = new Votes(party4,
-				Arrays.asList(new Vote(party4, a, 2), new Vote(party4, c, 2)));
+		Votes vote1AB = new Votes(party1, Arrays
+				.asList(new Vote(party1, a, 2, 9), new Vote(party1, b, 2, 9)));
+		Votes vote2AB = new Votes(party2, Arrays
+				.asList(new Vote(party2, a, 2, 9), new Vote(party2, b, 2, 9)));
+		Votes vote3C = new Votes(party3,
+				Arrays.asList(new Vote(party3, c, 2, 9)));
+		Votes vote4AC = new Votes(party4, Arrays
+				.asList(new Vote(party4, a, 2, 9), new Vote(party4, c, 2, 9)));
 		// party 1,2,4 vote for A, party 1,2 vote for B, party 3,4 vote for C.
 		// the biggest vote is P,Q,S
@@ -407,11 +409,12 @@
 	public void testNextPhase() {
 		// copy of above. todo cleanup
-		Votes vote1AB = new Votes(party1,
-				Arrays.asList(new Vote(party1, a, 2), new Vote(party1, b, 2)));
-		Votes vote2AB = new Votes(party2,
-				Arrays.asList(new Vote(party2, a, 2), new Vote(party2, b, 2)));
-		Votes vote3C = new Votes(party3, Arrays.asList(new Vote(party3, c, 2)));
-		Votes vote4AC = new Votes(party4,
-				Arrays.asList(new Vote(party4, a, 2), new Vote(party4, c, 2)));
+		Votes vote1AB = new Votes(party1, Arrays
+				.asList(new Vote(party1, a, 2, 9), new Vote(party1, b, 2, 9)));
+		Votes vote2AB = new Votes(party2, Arrays
+				.asList(new Vote(party2, a, 2, 9), new Vote(party2, b, 2, 9)));
+		Votes vote3C = new Votes(party3,
+				Arrays.asList(new Vote(party3, c, 2, 9)));
+		Votes vote4AC = new Votes(party4, Arrays
+				.asList(new Vote(party4, a, 2, 9), new Vote(party4, c, 2, 9)));
 		// party 1,2,4 vote for A, party 1,2 vote for B, party 3,4 vote for C.
 		// the biggest vote is P,Q,S
Index: protocol/src/test/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsSettingsTest.java
===================================================================
--- protocol/src/test/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsSettingsTest.java	(revision 21)
+++ protocol/src/test/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsSettingsTest.java	(revision 22)
@@ -68,7 +68,7 @@
 		profile2 = new ProfileRef("profile2");
 		profile3 = new ProfileRef("profile3");
-		ProfileList profiles1 = new ProfileList(Arrays.asList(profile1));
-		ProfileList profiles2 = new ProfileList(Arrays.asList(profile2));
-		ProfileList profiles3 = new ProfileList(Arrays.asList(profile3));
+		profiles1 = new ProfileList(Arrays.asList(profile1));
+		profiles2 = new ProfileList(Arrays.asList(profile2));
+		profiles3 = new ProfileList(Arrays.asList(profile3));
 
 		List<ProfileList> profiles = Arrays.asList(profiles1, profiles2,
@@ -137,4 +137,5 @@
 	}
 
+	@SuppressWarnings("unused")
 	@Test(expected = IllegalArgumentException.class)
 	public void testNullParties() {
@@ -145,4 +146,5 @@
 	}
 
+	@SuppressWarnings("unused")
 	@Test(expected = IllegalArgumentException.class)
 	public void testNoParties() {
@@ -153,4 +155,5 @@
 	}
 
+	@SuppressWarnings("unused")
 	@Test(expected = IllegalArgumentException.class)
 	public void testNullProfiles() {
@@ -159,4 +162,5 @@
 	}
 
+	@SuppressWarnings("unused")
 	@Test(expected = IllegalArgumentException.class)
 	public void testInsufficientProfiles() {
@@ -167,4 +171,5 @@
 	}
 
+	@SuppressWarnings("unused")
 	@Test(expected = IllegalArgumentException.class)
 	public void testNullSessionSettings() {
@@ -175,4 +180,5 @@
 	}
 
+	@SuppressWarnings("unused")
 	@Test(expected = IllegalArgumentException.class)
 	public void testOnePartyPerSession() {
@@ -189,18 +195,3 @@
 	}
 
-//	@Test
-//	public void makeCobTest() throws URISyntaxException {
-//		// Check that the cob party gets profile without the query part
-//		String profilebase = "ws://1.2.3.4:8080/profilesserver-a.b.c/websocket/get/someprofile";
-//		String partybase = "http://131.180.202.213:8080/partiesserver/run/";
-//		String query = "?a=2&partial=4";
-//		PartyWithProfile partyprofile = AllPermutationsSettings.makeCob(
-//				new PartyRef(partybase + AllPermutationsSettings.COB_PARTY),
-//				new ProfileRef(profilebase + query));
-//		assertEquals(profilebase,
-//				partyprofile.getProfile().getURI().toString());
-//		assertEquals(partybase + AllPermutationsSettings.COB_PARTY,
-//				partyprofile.getParty().getPartyRef().getURI().toString());
-//	}
-
 }
