void getNewMessages(DateTime loopTime) throws Exception{
        //Clean up of buffers goes here! Because we don't want to itterate over the new messages as we know
        //they are new! 
        
        //1. First, we clean up.
        for (Vessel v: theVessels){
                v.theTrackBuffer.cleanBuffer(theOptions.trackHistoryLength);
        }
        
        //2. We fetch messages in our time window
        
        //2.1 Setup a connection
        Class.forName("com.mysql.jdbc.Driver");
       
        Connection con = DriverManager.getConnection(theOptions.dbAISURL,theOptions.dbAISLogin,theOptions.dbAISPassword);
        Statement stmtIncomingMessages = con.createStatement();
        
        Integer noMessages;
        String qryMessages = "SELECT * FROM `" + theOptions.dbAISName + "`.`" + theOptions.dbAISTableName + "`";
        
        String minDate = loopTime.minusSeconds(theOptions.stepTime).toString("yyyy-MM-dd");
        String maxDate = loopTime.toString("yyyy-MM-dd");
        
        String minTime = loopTime.minusSeconds(theOptions.stepTime).toString("HH:mm:ss");
        String maxTime = loopTime.toString("HH:mm:ss");
        
        String filter = "";
        //2.2 determine some filter settings for the query
        if (theOptions.filterVessel) {
            filter = " WHERE mmsi=" + theOptions.filterMMSI.toString()
                    + " AND TIMESTAMPDIFF(SECOND, TIMESTAMP(date,time),'" + minDate + " " + minTime + "') <= 0"
                    + " AND TIMESTAMPDIFF(SECOND, TIMESTAMP(date,time),'" + maxDate + " " + maxTime + "') >= 0" 
                    + ";";
        }
        else {
            filter = " WHERE TIMESTAMPDIFF(SECOND, TIMESTAMP(date,time),'" + minDate + " " + minTime + "') <= 0"
                    + " AND TIMESTAMPDIFF(SECOND, TIMESTAMP(date,time),'" + maxDate + " " + maxTime + "') >= 0" 
                    + ";";
        } 
    
        //2.3 fetch messages
        ResultSet newMessages = stmtIncomingMessages.executeQuery(qryMessages + filter);
        
        noMessages = 0;
        
        try {
            newMessages.last();
            noMessages = newMessages.getRow();
            newMessages.first();
        }
        catch(Exception ex){
            return;
        }
        //3. Process the messages into position reports
        if (noMessages > 0) {
            do {
                DateTime timeStamp;
                Double theLon, theLat, lat, lon, cog, sog;
                Integer navStatus, theMMSI;
                String msgDate, msgTime;

                theLat = newMessages.getDouble("latitude");
                theLon = newMessages.getDouble("longtitude"); //don't ask
                
                if (theLon > 3.0 && theLon < 6.0){
                    if (theLat > 51.5 && theLat < 54.5){
                        theMMSI = newMessages.getInt("mmsi");

                        Vessel myVessel = addVessel(theMMSI, theVessels);

                        msgDate = newMessages.getDate("date").toString();
                        msgTime = newMessages.getTime("time").toString();

                        timeStamp = parseDBDateTime(msgDate,msgTime);

                        PositionReport newPoint = myVessel.theTrackBuffer.addPoint(timeStamp);

                        newPoint.latitude = newMessages.getDouble("latitude");
                        newPoint.longitude = newMessages.getDouble("longtitude"); //don't ask
                        newPoint.cog = newMessages.getDouble("cog");
                        newPoint.sog = newMessages.getDouble("sog");
                        newPoint.navigationStatus = newMessages.getInt("navigation_status");
                        newPoint.rot = newMessages.getInt("rot");
                    }
                }
            } while(newMessages.next());
        }
        
        //4. close and cleanup
        newMessages.close();
        stmtIncomingMessages.close();
        con.close(); 
        
    }