diff --git a/lib/addevent.dart b/lib/addevent.dart
index 7c885040bc6685830899a0221ab8fd9f254c3959..64b9bfd5efef12c250ebdb0154e3e657206976fd 100644
--- a/lib/addevent.dart
+++ b/lib/addevent.dart
@@ -75,6 +75,7 @@ class AddEvent extends StatelessWidget {
                 }).toList(),
                 onChanged: (value) {
                   currentEvent.store.urn = value.toString();
+                  currentEvent.store.id = availableDevice.getDeviceIdFromUrn(value.toString());
                 }
             ),
             TextFormField(
diff --git a/lib/datamodel.dart b/lib/datamodel.dart
index 86496ae3b7f186a51c3f1b6bc3ca91a542ac66b2..04c07e96c2228919d3a96cf837bea0ccabdc8b4f 100644
--- a/lib/datamodel.dart
+++ b/lib/datamodel.dart
@@ -64,8 +64,21 @@ class EventType{
 }
 
 
-abstract class DeviceStoreBase{
+abstract class DeviceStoreBase {
   List<Device> store = [];
+
+  int getDeviceIdFromUrn(String urn) {
+    for (var device in store) {
+      if (device.urn == urn) {
+        return device.id;
+      }
+    }
+    throw Exception('Device with urn:' + urn + ' was not found.');
+  }
+
+  void reset(){
+    store = [];
+  }
 }
 
 abstract class EventStoreBase{
@@ -90,6 +103,10 @@ class EventStoreInstance extends EventStoreBase {
   EventStoreInstance._internal() {
     store = [];
   }
+
+  void reset(){
+    store = [];
+  }
 }
 
 class EventCurrentInstance extends EventCurrentBase {
@@ -100,7 +117,11 @@ class EventCurrentInstance extends EventCurrentBase {
   }
 
   EventCurrentInstance._internal(){
-    store = Event(0, 'urn0', '', '', '', 'PENDING');
+    store = Event(-1, 'urn0', '', '', '', 'PENDING');
+  }
+
+  void reset(){
+    store = Event(-1, 'urn0', '', '', '', 'PENDING');
   }
 }
 
@@ -114,6 +135,11 @@ class EventTypeStoreInstance extends EventTypeStoreBase{
   EventTypeStoreInstance._internal(){
     store = [];
   }
+
+
+  void reset(){
+    store = [];
+  }
 }
 
 
diff --git a/lib/main.dart b/lib/main.dart
index 01284fbff2db1ab9ed367871a9eaab635205f95a..df29534dcdd0378935f262e834ed01835cff1eba 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -12,20 +12,26 @@ void main() {
   EventStoreInstance events = EventStoreInstance();
   EventTypeStoreInstance eventTypes = EventTypeStoreInstance();
   EventCurrentInstance currentEvent = EventCurrentInstance();
-  DeviceStoreInstance availableDevice = DeviceStoreInstance();
+  DeviceStoreInstance availableDevices = DeviceStoreInstance();
+
+  //Reset old data
+  events.reset();
+  eventTypes.reset();
+  currentEvent.reset();
+  availableDevices.reset();
+
 
-  
   // Add some dummy devices
   // TODO: load from shared preferences.
   // TODO: this shall be requested from sensor.awi.de after selecting a collection in configuration.
-  availableDevice.store.add(Device.fromJson({'id': 8311, 'urn':'station:neumayer_iii:awi_snow_sampler_1'}));
-  availableDevice.store.add(Device.fromJson({'id': 4086, 'urn':'acoustic_backscatter_sensor:test'}));
-  availableDevice.store.add(Device.fromJson({'id': 1393, 'urn':'vessel:polarstern:hydrosweep_ds3'}));
+  availableDevices.store.add(Device.fromJson({'id': 8311, 'urn':'station:neumayer_iii:awi_snow_sampler_1'}));
+  availableDevices.store.add(Device.fromJson({'id': 4086, 'urn':'acoustic_backscatter_sensor:test'}));
+  availableDevices.store.add(Device.fromJson({'id': 1393, 'urn':'vessel:polarstern:hydrosweep_ds3'}));
 
   // Fill the textboxes in addevent with some usefull data.
   // TODO: store this in shared preferences so that last entered data reappears when restarting the app.
   currentEvent.store.urn = 'acoustic_backscatter_sensor:test';
-  currentEvent.store.id = 1234;
+  currentEvent.store.id = 4086;
   currentEvent.store.description = 'blabla';
   currentEvent.store.label = 'PS129_ABC';
   currentEvent.store.type = 'Deployment';