diff --git a/deep_sequencing_unit/source/java/ch/ethz/bsse/cisd/dsu/tracking/dto/TrackingStateDTO.java b/deep_sequencing_unit/source/java/ch/ethz/bsse/cisd/dsu/tracking/dto/TrackingStateDTO.java
index c311de09d59d906ec4d065b3847235a239b6b6bf..7843cce11fa6d01555774639c5b2068bcab48435 100644
--- a/deep_sequencing_unit/source/java/ch/ethz/bsse/cisd/dsu/tracking/dto/TrackingStateDTO.java
+++ b/deep_sequencing_unit/source/java/ch/ethz/bsse/cisd/dsu/tracking/dto/TrackingStateDTO.java
@@ -24,14 +24,14 @@ public class TrackingStateDTO
 
     private Set<Long> alreadyTrackedSampleIdsProcessed;
 
-    private int lastSeenDatasetId;
+    private long lastSeenDatasetId;
 
-    public int getLastSeenDatasetId()
+    public long getLastSeenDatasetId()
     {
         return lastSeenDatasetId;
     }
 
-    public void setLastSeenDatasetId(int lastSeenDatasetId)
+    public void setLastSeenDatasetId(long lastSeenDatasetId)
     {
         this.lastSeenDatasetId = lastSeenDatasetId;
     }
diff --git a/deep_sequencing_unit/source/java/ch/ethz/bsse/cisd/dsu/tracking/main/FileBasedTrackingDAO.java b/deep_sequencing_unit/source/java/ch/ethz/bsse/cisd/dsu/tracking/main/FileBasedTrackingDAO.java
index 0050db9caf0522e23b32d0e66e522cc8e9823d0c..d58f867c982695db072cf681948e2eb5f105a804 100644
--- a/deep_sequencing_unit/source/java/ch/ethz/bsse/cisd/dsu/tracking/main/FileBasedTrackingDAO.java
+++ b/deep_sequencing_unit/source/java/ch/ethz/bsse/cisd/dsu/tracking/main/FileBasedTrackingDAO.java
@@ -74,7 +74,7 @@ public class FileBasedTrackingDAO implements ITrackingDAO
             String[] datasetId = lines.get(0).split("\t");
             String[] toBeProcessed = lines.get(1).split("\t");
             String[] processed = lines.get(2).split("\t");
-            state.setLastSeenDatasetId(Integer.parseInt(datasetId[1]));
+            state.setLastSeenDatasetId(Long.parseLong(datasetId[1]));
             state.setAlreadyTrackedSampleIdsToBeProcessed(parseIds(toBeProcessed));
             state.setAlreadyTrackedSampleIdsProcessed(parseIds(processed));
             return state;
diff --git a/deep_sequencing_unit/source/java/ch/ethz/bsse/cisd/dsu/tracking/main/TrackingBO.java b/deep_sequencing_unit/source/java/ch/ethz/bsse/cisd/dsu/tracking/main/TrackingBO.java
index e2d624e083eaad44446e2264f9df64da2c618633..515f8e3327bfcbdd77ec2796c028ad0910ec1ad9 100644
--- a/deep_sequencing_unit/source/java/ch/ethz/bsse/cisd/dsu/tracking/main/TrackingBO.java
+++ b/deep_sequencing_unit/source/java/ch/ethz/bsse/cisd/dsu/tracking/main/TrackingBO.java
@@ -219,7 +219,7 @@ public class TrackingBO
                     .getSequencingSamplesProcessed());
             state.setAlreadyTrackedSampleIdsProcessed(sequencingSamplesProcessed);
 
-            int lastSeenDatasetId =
+            long lastSeenDatasetId =
                     calcMaxId(changedEntities.getDataSets(), prevState.getLastSeenDatasetId());
             state.setLastSeenDatasetId(lastSeenDatasetId);
             return state;
@@ -234,15 +234,14 @@ public class TrackingBO
             }
         }
 
-        private static int calcMaxId(List<? extends IIdentifiable> entities, int initialValue)
+        private static long calcMaxId(List<? extends IIdentifiable> entities, long initialValue)
         {
             long max = initialValue;
             for (IIdentifiable entity : entities)
             {
                 max = Math.max(max, entity.getId());
             }
-            // TODO 2009-12-01, Tomasz Pylak: refactor ids to long everywhere
-            return (int) max;
+            return max;
         }
     }
 }
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/IDatasetListingQuery.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/IDatasetListingQuery.java
index 16b27bc0b08467481bc311454f225f7fd69f9ac3..1f04b0f1aa244699b702a6464203b01e6bb03ddd 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/IDatasetListingQuery.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/IDatasetListingQuery.java
@@ -68,7 +68,7 @@ public interface IDatasetListingQuery extends TransactionQuery, IPropertyListing
     @Select(sql = "SELECT * FROM data JOIN external_data ON data.id = external_data.data_id"
             + "    WHERE data.id > ?{2} AND data.samp_id IN (SELECT id FROM samples s WHERE s.saty_id=?{1})", fetchSize = FETCH_SIZE)
     public DataIterator<DatasetRecord> getNewDataSetsForSampleType(long sampleTypeId,
-            int lastSeenDatasetId);
+            long lastSeenDatasetId);
 
     /**
      * Returns datasets from store with given id that have status equal 'AVAILABLE' and were
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/TrackingDataSetCriteria.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/TrackingDataSetCriteria.java
index b624fb96dcd6b5a3cc02ceff88f0dde01b48aac6..c919cd0ad141884e98e4c147a56986f5b76f1b2a 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/TrackingDataSetCriteria.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/TrackingDataSetCriteria.java
@@ -35,9 +35,9 @@ public class TrackingDataSetCriteria implements IsSerializable, Serializable
 
     private final String connectedSampleTypeCode;
 
-    private int lastSeenDataSetId;
+    private long lastSeenDataSetId;
 
-    public TrackingDataSetCriteria(String connectedSampleTypeCode, int lastSeenDataSetId)
+    public TrackingDataSetCriteria(String connectedSampleTypeCode, long lastSeenDataSetId)
     {
         assert connectedSampleTypeCode != null;
         this.lastSeenDataSetId = lastSeenDataSetId;
@@ -49,12 +49,12 @@ public class TrackingDataSetCriteria implements IsSerializable, Serializable
         return connectedSampleTypeCode;
     }
 
-    public int getLastSeenDataSetId()
+    public long getLastSeenDataSetId()
     {
         return lastSeenDataSetId;
     }
 
-    public void setLastSeenDataSetId(int lastSeenDataSetId)
+    public void setLastSeenDataSetId(long lastSeenDataSetId)
     {
         this.lastSeenDataSetId = lastSeenDataSetId;
     }