Index: components/poker/sections/Messages.jsx
===================================================================
--- components/poker/sections/Messages.jsx	(revision 189cd8fbb5d5a78dbc96b7dd32349d209b87bd13)
+++ components/poker/sections/Messages.jsx	(revision aac3b2b897972cd33d5372848c2cbac2e4e97ccc)
@@ -24,10 +24,11 @@
     return (
         <div className="pokerMessagesContainer">
-            { playerState.pokerGame.table.started && playerState.pokerGame.table.ended && playerState.pokerGame.table.winners.length === 1 && <p>Game over - {playerState.pokerGame.table.winners[0]?.displayName} won ${playerState.pokerGame.table.winners[0]?.wonAmount} with a {playerState.pokerGame.table.winners[0]?.hand?.hand} combination! Congratulations.</p> }
-            { playerState.pokerGame.table.started && playerState.pokerGame.table.ended && playerState.pokerGame.table.winners.length > 1 && <p>Game over - {playerState.pokerGame.table.winners.map(e=>e.displayName).join(", ")} drew!</p> }
-            { playerState.pokerGame.table.started && playerState.pokerGame.table.ended && <p>New game will start soon.</p> }
+            { playerState.pokerGame.table.ended && playerState.pokerGame.table.onlyOnePlayerLeft && <p>Game over - {playerState.pokerGame.table.winners[0]?.displayName} won ${playerState.pokerGame.table.winners[0]?.wonAmount} because everyone else folded! Congratulations.</p> }
+            { playerState.pokerGame.table.ended && !playerState.pokerGame.table.onlyOnePlayerLeft && playerState.pokerGame.table.winners.length === 1 && <p>Game over - {playerState.pokerGame.table.winners[0]?.displayName} won ${playerState.pokerGame.table.winners[0]?.wonAmount} with a {playerState.pokerGame.table.winners[0]?.hand?.hand} combination! Congratulations.</p> }
+            { playerState.pokerGame.table.ended && playerState.pokerGame.table.winners.length > 1 && <p>Game over - {playerState.pokerGame.table.winners.map(e=>e.displayName).join(", ")} drew!</p> }
+            { playerState.pokerGame.table.ended && <p>New game will start soon.</p> }
 
             { playerState.pokerGame.table.started && !playerState.pokerGame.table.ended && <p>Round {playerState.pokerGame.table.round}/4{roundMessage}</p> }
-            { !playerState.pokerGame.table.started && <p>Waiting for coordinator {playerState.pokerGame.table.creator} to start the game.</p> }
+            { !playerState.pokerGame.table.started && !playerState.pokerGame.table.ended && <p>Waiting for coordinator {playerState.pokerGame.table.creator} to start the game.</p> }
             { playerState.pokerGame.table.started && !playerState.pokerGame.table.ended && <p>{turnMessage}</p> }
             { playerState.pokerGame.table.started && !playerState.pokerGame.table.ended && <p>{callMessage}</p> }
Index: components/poker/sections/PickATable.jsx
===================================================================
--- components/poker/sections/PickATable.jsx	(revision 189cd8fbb5d5a78dbc96b7dd32349d209b87bd13)
+++ components/poker/sections/PickATable.jsx	(revision aac3b2b897972cd33d5372848c2cbac2e4e97ccc)
@@ -49,9 +49,9 @@
                 <h3>Pick a table:</h3>
                 <div onClick={(e) => joinATable(e)}>
-                    {playerState.pokerGame.tables.map(table => (
+                    {playerState.pokerGame.tables.filter(table=>table.started===false).map(table => (
                         <div data-table={table.id} key={table.id}>
                             <p data-table={table.id}>Table name: {table.name}</p>
                             <p data-table={table.id}>Creator: {table.creator}</p>
-                            <p data-table={table.id}>Players: {table.players.length}/8</p>
+                            <p data-table={table.id}>Players: {table.players.filter(e=>e.isGhost===false).length}/8</p>
                             <p data-table={table.id}>Join</p>
                         </div>
Index: components/poker/sections/PlayButtons.jsx
===================================================================
--- components/poker/sections/PlayButtons.jsx	(revision 189cd8fbb5d5a78dbc96b7dd32349d209b87bd13)
+++ components/poker/sections/PlayButtons.jsx	(revision aac3b2b897972cd33d5372848c2cbac2e4e97ccc)
@@ -60,5 +60,5 @@
     return (
       <div className="pokerPlayButtonsContainer">
-        {!playerState.pokerGame.table.started && playerState.pokerGame.player.isCoordinator && playerState.pokerGame.player.isSatDown && <button className="secondaryButton" onClick={() => startGame()}>Start game</button>}
+        {!playerState.pokerGame.table.started && !playerState.pokerGame.table.ended && playerState.pokerGame.player.isCoordinator && playerState.pokerGame.player.isSatDown && <button className="secondaryButton" onClick={() => startGame()}>Start game</button>}
         {!playerState.pokerGame.table.started && !playerState.pokerGame.player.isSatDown && <button className="secondaryButton" onClick={() => sitDown()}>Take a seat</button>}
       </div>
Index: pages/api/poker/index.js
===================================================================
--- pages/api/poker/index.js	(revision 189cd8fbb5d5a78dbc96b7dd32349d209b87bd13)
+++ pages/api/poker/index.js	(revision aac3b2b897972cd33d5372848c2cbac2e4e97ccc)
@@ -47,4 +47,5 @@
             },
         }],
+        onlyOnePlayerLeft: false,
         winners: [],
         splitWinners: false,
@@ -281,5 +282,5 @@
             const { success, table } = getTableAndPlayer(req.query.session_id)
 
-            if (success && !table.started) {
+            if (success && !table.started && !table.ended && table.players.filter(e=>e.isSatDown===true).length >= 2) {
                 table.players.forEach(player => {
                     axios.get(`${process.env.HOME_URL}/api/postgre/?action=check_if_logged_in&session_id=${player.id}`).then(postgreRes => {
@@ -342,6 +343,11 @@
                 player.isFolded = true;
 
-                if (table.players[table.turnIdx] !== undefined && table.players[table.turnIdx] === player) {
-                    setNextPlayerIdx(table.id);
+                if (table.started) {
+                    if (table.players[table.turnIdx] !== undefined && table.players[table.turnIdx] === player) {
+                        setNextPlayerIdx(table.id);
+                    }
+                }
+                else {
+                    table.players = table.players.filter(e=>e.isGhost === false);
                 }
             }
Index: pages/api/poker/tableSpecific.js
===================================================================
--- pages/api/poker/tableSpecific.js	(revision 189cd8fbb5d5a78dbc96b7dd32349d209b87bd13)
+++ pages/api/poker/tableSpecific.js	(revision aac3b2b897972cd33d5372848c2cbac2e4e97ccc)
@@ -62,6 +62,20 @@
     const tableIdx = tables.map(e=>e.id).indexOf(tableId);
 
-    if (tables[tableIdx] !== undefined) {
-        const table = tables[tableIdx];
+    if (tables[tableIdx] !== undefined && !tables[tableIdx].ended) {
+        const table = tables[tableIdx];
+
+        const remainingPlayers = table.players.filter(e=>e.isSatDown===true).filter(e=>e.isGhost===false);
+        if (remainingPlayers.length === 1) {
+            setWinnerDirect(table.id, remainingPlayers[0]);
+
+            return ;
+        }
+
+        const remainingPlayersWithCredits = table.players.filter(e=>e.isSatDown===true).filter(e=>e.isGhost===false).filter(e=>e.isFolded===false).filter(e=>e.credits > 0);
+        if (remainingPlayersWithCredits.length === 1) {
+            progressRoundTillTheEnd(table.id);
+
+            return ;
+        }
 
         if (table.turnTimeout !== null) clearTimeout(table.turnTimeout);
@@ -83,5 +97,5 @@
                         if (table.players[table.turnIdx] !== undefined) {
                             table.players[table.turnIdx].isFolded = true;
-
+                            
                             setNextPlayerIdx(table.id);
                         }
@@ -136,5 +150,5 @@
         table.ended = false;
         table.round = 0;
-        table.turnIdx = 0;
+        table.turnIdx = -1;
         table.turnTimeout = null;
         table.pot = 0;
@@ -143,6 +157,5 @@
         table.deck = [...deck];
 
-        table.players = table.players.filter(e=>e.isGhost === false);
-        table.players = table.players.filter(e=>e.credits >= 20);
+        table.players = table.players.filter(e=>e.isGhost === false).filter(e=>e.credits >= 20);
 
         table.players.forEach(player => {
@@ -157,4 +170,6 @@
             }
         })
+
+        table.onlyOnePlayerLeft = false;
         table.winners = [];
         table.splitWinners = false;
@@ -168,7 +183,4 @@
     if (tables[tableIdx] !== undefined) {
         const table = tables[tableIdx];
-
-        const satDownPlayers = table.players.filter(e => e.isSatDown === true);
-        const satDownCount = satDownPlayers.length;
 
         table.players.forEach(player => {
@@ -212,4 +224,21 @@
 }
 
+export function setWinnerDirect(tableId, player) {
+    const tableIdx = tables.map(e=>e.id).indexOf(tableId);
+
+    if (tables[tableIdx] !== undefined) {
+        const table = tables[tableIdx];
+
+        table.turnIdx = -1;
+        table.started = false;
+        table.ended = true;
+
+        table.onlyOnePlayerLeft = true;
+        table.winners = [player];
+
+        giveMoneyToTheWinners(table.id);
+    }
+}
+
 export function setWinner(tableId) {
     const tableIdx = tables.map(e=>e.id).indexOf(tableId);
@@ -259,4 +288,23 @@
 }
 
+export function progressRoundTillTheEnd(tableId) {
+    const tableIdx = tables.map(e=>e.id).indexOf(tableId);
+
+    if (tables[tableIdx] !== undefined) {
+        const table = tables[tableIdx];
+
+        while (table.round < 4) {
+            table.round++;
+            getCardsOnTable(table.id);
+        }
+
+        table.started = false;
+        table.ended = true;
+        if (table.ended && table.winners.length === 0) {
+            setWinner(table.id);
+        }
+    }
+}
+
 export function progressRoundIfNeeded(tableId) {
     const tableIdx = tables.map(e=>e.id).indexOf(tableId);
@@ -277,4 +325,5 @@
             }
             else {
+                table.started = false;
                 table.ended = true;
             }
Index: pages/api/postgre/index.js
===================================================================
--- pages/api/postgre/index.js	(revision 189cd8fbb5d5a78dbc96b7dd32349d209b87bd13)
+++ pages/api/postgre/index.js	(revision aac3b2b897972cd33d5372848c2cbac2e4e97ccc)
@@ -413,6 +413,7 @@
                     // Already logged in
                     res.json({
-                      success: false,
-                      message: 'You are already logged in',
+                      success: true,
+                      message: 'Login successful',
+                      session: session,
                     })
                   }
