diff --git a/warden3/warden_server/warden3.0-alpha.sql b/warden3/warden_server/warden3.0-alpha.sql
index fa0414705861833cfa1b85172b22425d0f78c5a2..ab668c7d0d836b39dadb310e59d28d07704b49ef 100644
--- a/warden3/warden_server/warden3.0-alpha.sql
+++ b/warden3/warden_server/warden3.0-alpha.sql
@@ -119,7 +119,8 @@ INSERT INTO `clients` (`id`, `hostname`, `registered`, `requestor`, `note`, `val
 (23, 'nfsen.ics.muni.cz', '0000-00-00 00:00:00', '', '', 1, 1, 0),
 (25, 'vinovago.cesnet.cz', '0000-00-00 00:00:00', '', '', 1, 1, 0),
 (26, 'ward.tul.cz', '0000-00-00 00:00:00', '', '', 1, 1, 0),
-(28, 'kostik.zcu.cz', '0000-00-00 00:00:00', 'kostenec@civ.zcu.cz', '', 1, 1, 1);
+(28, 'kostik.zcu.cz', '0000-00-00 00:00:00', 'kostenec@civ.zcu.cz', '', 1, 1, 1),
+(29, 'grey.cesnet.cz', '2014-12-11 13:51:14', 'ph@cesnet.cz', '', 1, 1, 1);
 
 -- --------------------------------------------------------
 
@@ -132,7 +133,7 @@ CREATE TABLE IF NOT EXISTS `events` (
   `detected_epoch` int(11) NOT NULL,
   `received` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
   `detected` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
-  `client_id` int(11) NOT NULL,
+  `service_id` int(11) NOT NULL,
   `data` text NOT NULL,
   `valid` tinyint(1) NOT NULL DEFAULT '1',
   `origin` varchar(64) NOT NULL,
@@ -140,7 +141,7 @@ CREATE TABLE IF NOT EXISTS `events` (
   `origin_long` varchar(64) NOT NULL,
   PRIMARY KEY (`id`),
   KEY `detected` (`detected`),
-  KEY `id` (`id`,`client_id`)
+  KEY `id` (`id`,`service_id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
 
 -- --------------------------------------------------------
@@ -175,11 +176,11 @@ CREATE TABLE IF NOT EXISTS `event_tag_mapping` (
 
 CREATE TABLE IF NOT EXISTS `last_events` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
-  `client_id` int(11) NOT NULL,
+  `service_id` int(11) NOT NULL,
   `event_id` int(11) NOT NULL,
   `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
   PRIMARY KEY (`id`),
-  KEY `client_id` (`client_id`,`event_id`)
+  KEY `service_id` (`service_id`,`event_id`)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
 
 -- --------------------------------------------------------
@@ -226,7 +227,7 @@ INSERT INTO `services` (`service_id`, `client_id`, `registered`, `requestor`, `s
 (17, 17, '0000-00-00 00:00:00', '', 'synscandetector_1_0', '', 1, 'org.liberouter.collector.synscandetector_1_0', 1, 0),
 (18, 18, '0000-00-00 00:00:00', '', 'kippohoneypot', '', 1, 'cz.cesnet.holly.kippohoneypot', 1, 0),
 (19, 19, '0000-00-00 00:00:00', '', 'dionaeahoneypot', '', 1, 'cz.cesnet.kryten.dionaeahoneypot', 1, 0),
-(20, 29, '0000-00-00 00:00:00', '', 'mentat', '', 1, 'cz.cesnet.mentat.mentat', 1, 0),
+(20, 20, '0000-00-00 00:00:00', '', 'mentat', '', 1, 'cz.cesnet.mentat.mentat', 1, 0),
 (21, 21, '0000-00-00 00:00:00', '', 'kippo', '', 1, 'cz.slu.opf.miel.kippo', 1, 0),
 (22, 23, '0000-00-00 00:00:00', '', 'honeyscan', '', 1, 'cz.muni.ics.nfsen.honeyscan', 1, 0),
 (23, 23, '0000-00-00 00:00:00', '', 'scandetector_1_0', '', 1, 'cz.muni.ics.nfsen.scandetector_1_0', 1, 0),
@@ -236,7 +237,8 @@ INSERT INTO `services` (`service_id`, `client_id`, `registered`, `requestor`, `s
 (27, 26, '0000-00-00 00:00:00', '', 'kippo', '', 1, 'cz.tul.ward.kippo', 1, 0),
 (28, 28, '0000-00-00 00:00:00', 'kostenec@civ.zcu.cz', 'com.example.test-node', '', 1, 'com.example.test-node', 0, 0),
 (29, 28, '0000-00-00 00:00:00', 'kostenec@civ.zcu.cz', 'com.example.test-node2', '', 1, 'com.example.test-node2', 0, 0),
-(30, 28, '0000-00-00 00:00:00', 'kostenec@civ.zcu.cz', 'Test', '', 1, 'com.example.test-node3', 0, 0);
+(30, 28, '0000-00-00 00:00:00', 'kostenec@civ.zcu.cz', 'Test', '', 1, 'com.example.test-node3', 0, 0),
+(31, 29, '2014-12-11 13:51:18', 'ph@cesnet.cz', 'Test', '', 1, 'cz.cesnet.grey.test', 1, 0);
 
 -- --------------------------------------------------------
 
diff --git a/warden3/warden_server/warden_server.py b/warden3/warden_server/warden_server.py
index e05fdbae92d72c7bb19135dec62c9eb0ad852d8b..4be435506b28d84c2b892e38c0558afe8775125f 100755
--- a/warden3/warden_server/warden_server.py
+++ b/warden3/warden_server/warden_server.py
@@ -193,16 +193,20 @@ class X509Authenticator(NoAuthenticator):
 
 
     def authorize(self, env, client, method, event, args):
+        logging.debug("authorize: Client: " + str(client))
+       
         # Authorize for debug
         if (method == 'getDebug'):
             return client if client[0]['debug'] == 1 else None
 
         cl = None
-        service = event['Node'][0]['Name']
+        identity = event['Node'][0]['Name']
         test = 'Test' in event['Category']        
         
+        logging.debug("Event identity: " + identity)
+
         for clx in client:
-            if clx['service'] == service:
+            if clx['identity'] == identity:
                 cl = clx
                 break
 
@@ -277,6 +281,7 @@ class MySQL(Object):
         format_strings = ','.join(['%s'] * len(name))
         self.crs.execute("SELECT cl.`id`, cl.`hostname`, s.`service`, s.`service_id`, s.`identity`, cl.`read`, s.`write`, s.`test`, cl.`debug` FROM `clients` cl LEFT JOIN `services` s ON cl.`id` = s.`client_id` WHERE cl.`valid` = 1 AND s.`valid` = 1 AND `hostname` IN (%s)" % format_strings, tuple(name))
         row = self.crs.fetchall()
+        logging.debug("Client/service info: " + str(row))
         
         return row if row else None
 
@@ -359,10 +364,10 @@ class MySQL(Object):
 
             if group is not None:
                 for identity in json.loads(group):
-                    sqltemp['group'] += ("cl.identity LIKE '%s' AND " % (identity)) 
+                    sqltemp['group'] += ("s.identity LIKE '%s' AND " % (identity)) 
             if nogroup is not None:
                 for identity in json.loads(nogroup):
-                    sqltemp['group'] += ("cl.identity NOT LIKE '%s' AND " % (identity)) 
+                    sqltemp['group'] += ("s.identity NOT LIKE '%s' AND " % (identity)) 
 
             # logging.debug(sqltemp['group'][:-4])
             sqlwhere.append(sqltemp['group'][:-4])
@@ -374,8 +379,8 @@ class MySQL(Object):
         #sqlwhere = sqlwhere[:-4]
         and_op = "" if not sqlwhere_string else "AND"
 
-        # logging.debug("SELECT e.id, e.data FROM clients cl RIGHT JOIN events e ON cl.id = e.client_id WHERE e.id > %s AND %s %s e.valid = 1 LIMIT %s" % (str(id), sqlwhere_string, and_op, str(count)))
-        self.crs.execute("SELECT e.id, e.data FROM clients cl RIGHT JOIN events e ON cl.id = e.client_id WHERE e.id > %s AND %s %s e.valid = 1 LIMIT %s" % (str(id), sqlwhere_string, and_op, str(count)))
+        logging.debug("SELECT e.id, e.data FROM services s RIGHT JOIN events e ON s.id = e.service_id WHERE e.id > %s AND %s %s e.valid = 1 LIMIT %s" % (str(id or 0), sqlwhere_string, and_op, str(count)))
+        self.crs.execute("SELECT e.id, e.data FROM services s RIGHT JOIN events e ON s.service_id = e.service_id WHERE e.id > %s AND %s %s e.valid = 1 LIMIT %s" % (str(id or 0), sqlwhere_string, and_op, str(count)))
         row = self.crs.fetchall()
 
         if row:
@@ -397,8 +402,8 @@ class MySQL(Object):
         
         for event in events:
             try:
-                # logging.debug("INSERT INTO events (detected,received,client_id,data) VALUES ('%s', NOW(), '%s', '%s')" % (event['DetectTime'], client['id'], self.con.escape_string(str(event))))
-                self.crs.execute("INSERT INTO events (detected,received,client_id,data) VALUES ('%s', NOW(), '%s', '%s')" % (event['DetectTime'], client['id'], self.con.escape_string(str(event))))
+                # logging.debug("INSERT INTO events (detected,received,service_id,data) VALUES ('%s', NOW(), '%s', '%s')" % (event['DetectTime'], client['id'], self.con.escape_string(str(event))))
+                self.crs.execute("INSERT INTO events (detected,received,service_id,data) VALUES ('%s', NOW(), '%s', '%s')" % (event['DetectTime'], client['service_id'], self.con.escape_string(str(event))))
                 lastid = self.crs.lastrowid
                 # logging.debug(str(lastid))
                 for cat in event['Category']:
@@ -415,16 +420,15 @@ class MySQL(Object):
                     self.crs.execute("INSERT INTO event_tag_mapping (event_id,tag_id) VALUES ('%s', '%s')" % (str(lastid), str(tag_id)))    
 
                 self.con.commit()
-            except:
+            except Exception as e:
                 self.con.rollback()
-                raise Error("Data storing error", 00, detail={'event': event})
-                errs.append({"event": event})
+                errs.append({"event": event, "error": str(e)})
     
         return errs
 
     def insertLastReceivedId(self, client, id):
-        logging.debug("INSERT INTO last_events(client_id, event_id, timestamp) VALUES(%s, %s, NOW())" % (str(client[0]['id']), id))
-        self.crs.execute("INSERT INTO last_events(client_id, event_id, timestamp) VALUES(%s, %s, NOW())" % (str(client[0]['id']), id))
+        logging.debug("INSERT INTO last_events(service_id, event_id, timestamp) VALUES(%s, %s, NOW())" % (str(client[0]['service_id']), id))
+        self.crs.execute("INSERT INTO last_events(service_id, event_id, timestamp) VALUES(%s, %s, NOW())" % (str(client[0]['service_id']), id))
 
     def getLastEventId(self):
         self.crs.execute("SELECT MAX(id) as id FROM events")
@@ -434,11 +438,11 @@ class MySQL(Object):
 
     def getLastReceivedId(self, client):
         logging.debug("IN getLastReceivedId")
-        client_id = client[0]['id'] 
-        logging.debug("getLastReceivedId (client_id) = %s", str(client_id))
+        service_id = client[0]['service_id'] 
+        logging.debug("getLastReceivedId (service_id) = %s", str(service_id))
 
-        logging.debug("SELECT MAX(event_id) as id FROM last_events WHERE client_id = %s" % (str(client_id)))
-        self.crs.execute("SELECT MAX(event_id) as id FROM last_events WHERE client_id = %s" % (str(client_id)))
+        logging.debug("SELECT MAX(event_id) as id FROM last_events WHERE service_id = %s" % (str(service_id)))
+        self.crs.execute("SELECT MAX(event_id) as id FROM last_events WHERE service_id = %s" % (str(service_id)))
         row = self.crs.fetchone()
 
         logging.debug("getLastReceivedId - %s" % str(row['id']))
@@ -748,9 +752,9 @@ class WardenHandler(Object):
             count = min(count, self.get_events_limit)
 
         logging.debug("getEvents - count: %s" % count)
-        res = self.db.fetch_events(_client, id, count, cat, nocat, tag, notag, group, nogroup)
+        res = self.db.fetch_events(_client, id or 0, count, cat, nocat, tag, notag, group, nogroup)
         logging.info("getEvents(%d, %d, %s, %s, %s, %s, %s, %s): sending %d events" % (
-            id, count, cat, nocat, tag, notag, group, nogroup, len(res["events"])))
+            id or 0, count, cat, nocat, tag, notag, group, nogroup, len(res["events"])))
 
         self.db.insertLastReceivedId(_client, res['lastid'])
         logging.debug("lastid inserting: %s" % {'lastid': res['lastid'], 'client' : _client})