@Override
    public void mouseReleased(MouseEvent e) {
        //Don't want multiple threads in here really
        synchronized (lock) {
            try {
                if (e.getX() < X_BOARD_OFFSET || e.getX() > (getWidth() - X_BOARD_OFFSET)) {
                    //Clicked off the board, nothing to do with us.
                    if (activeMove != null) activeMove.unhideCards(game);
                    activeMove = null;
                    return;
                }

                if (NUMBER_CLICKS == 1) {
                    doubleClick(e);
                    NUMBER_CLICKS = 0;
                } else if (clickedOnDeck(e)) {
                    //Do nothing

                } else if (e.getY() < Y_BOARD_OFFSET) {
                    processMoveToTopRow(e);
                } else {
                    processMoveToBoard(e);
                }
                if (activeMove != null) activeMove.unhideCards(game);
                activeMove = null;
            } finally {
                this.repaint();
            }
            if (game.hasWon()) {
                int elapsedTime = (int) (System.currentTimeMillis() - game.getStartTime());
                StorageManager.win(elapsedTime, game.getNumMoves());
                String[] options = new String[]{"Play Again", "Quit"};
                int result = JOptionPane.showOptionDialog(CardFrame.showStats(), "Congratulations! You have won.\n Time: " + (elapsedTime / 1000) + " s\nMoves: " + game.getNumMoves(), "Win!", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
                if (result == JOptionPane.YES_OPTION) {
                    game.restart();

                } else {
                    System.exit(0);
                }
            }
        }
    }