Subject: Built motion from commit 8c5ee34.|0.0.141
From: Daniele Cinti <[email-masked]>
Date: Wed, 14 Sep 2016 13:58:58 +0000 (+0200)

Built motion from commit 8c5ee34.|0.0.141
---

diff --git a/package.json b/package.json
index 6ca1f97..4fcbbc5 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,6 @@
     "bluebird": "^3.3.3",
     "body-parser": "~1.14.1",
     "child-process-promise": "^2.0.2",
-    "cluster-emitter": "^0.5.0-SNAPSHOT.1388501015412",
     "composable-middleware": "^0.3.0",
     "compression": "~1.6.0",
     "connect-flash": "^0.1.1",
diff --git a/public/app/4089734f.app.js b/public/app/2fcb48e4.app.js
similarity index 99%
rename from public/app/4089734f.app.js
rename to public/app/2fcb48e4.app.js
index d89c85f..ddff560 100644
--- a/public/app/4089734f.app.js
+++ b/public/app/2fcb48e4.app.js
@@ -13,11 +13,11 @@ return k.get().$promise.then(function(b){a.voiceMohs=b.rows,e.syncUpdates("voice
diff --git a/public/index.html b/public/index.html
index e91252b..b01b869 100644
--- a/public/index.html
+++ b/public/index.html
@@ -50,7 +50,7 @@
     <![endif]-->
     <script src="app/cf8af6fa.vendor.js"></script>
 
-    <script src="app/4089734f.app.js"></script>
+    <script src="app/2fcb48e4.app.js"></script>
 
     <!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
     <!-- BEGIN CORE PLUGINS -->
diff --git a/release-notes/changelog_0.0.141.txt b/release-notes/changelog_0.0.141.txt
index 13474aa..c1347f4 100644
--- a/release-notes/changelog_0.0.141.txt
+++ b/release-notes/changelog_0.0.141.txt
@@ -1,5 +1,22 @@
 # xCALLY MOTION Changelog
 
+- * 7c7b434 - 2016-09-14: server side app.js update 
+- * 2856612 - 2016-09-14: server side config/triggers update process.on 
+- * d56a499 - 2016-09-14: server side config ami/ami.js 
+- * 27e1728 - 2016-09-14: remove ami from integration 
+- * 043e9a6 - 2016-09-14: emitter removed 
+- * e487445 - 2016-09-14: Removed emitter from models 
+- * 2f95bdc - 2016-09-14: remove emitter 
+- * dbaa2dc - 2016-09-14: fix motion dialer process list 
+- * 0fba111 - 2016-09-14: model update (remove emitter) 
+- * 0c6cf4f - 2016-09-14: server side update models action 
+- * ecc75b9 - 2016-09-14: server side app.js 
+- * 5626b13 - 2016-09-14: package.json 
+- * 7933ed4 - 2016-09-14: server services/dashboard 
+- * f48858c - 2016-09-14: server side models user update 
+- * 5b85fcd - 2016-09-14: server side config ami update 
+- * 5077c17 - 2016-09-14: client side app dashboard/voice 
+- * afe2d4b - 2016-09-14: automation: code clean and add comments 
 - * 78266a6 - 2016-09-14: remove event emitter 
 - * 2eb400c - 2016-09-14: Fixed seedp 
 - * 3564fb1 - 2016-09-14: server side app.js, routes.js 
@@ -101,5 +118,4 @@
 - * a8c5748 - 2016-09-07: server side config ami index.js update 
 - * dbb9185 - 2016-09-07: package.json 
 - * baeb38d - 2016-09-07: Added custom variables check for urlforward trigger action; Moved all http functions under urlforward. 
-- * 0a64ca2 - 2016-09-07: Updated ui-select; Fixed sounds and announces in queue settings. 
 
diff --git a/server/app.js b/server/app.js
index 6a26e4e..4ca80a4 100644
--- a/server/app.js
+++ b/server/app.js
@@ -81,10 +81,10 @@ models
     require('./config/automations/mail')();
     require('./config/automations/fax')();
     require('./config/automations/chat')();
-    // require('./config/triggers')(ami);
-    // require('./config/scheduler')();
-    // require('./config/imap')();
-    // require('./config/smtp')();
+    require('./config/triggers')(cpAmi);
+    require('./config/scheduler')();
+    require('./config/imap')();
+    require('./config/smtp')();
     require('./config/sms')();
     require('./config/chat')();
     require('./config/openchannel')();
diff --git a/server/config/ami/action.js b/server/config/ami/action.js
index fb94ae7..2fa6d11 100644
--- a/server/config/ami/action.js
+++ b/server/config/ami/action.js
@@ -1,28 +1,45 @@
 'use strict';
 
-var moment = require('moment');
-var util = require('util');
-var Promise = require('bluebird');
-
-var Agent = require('../../models').User;
-var Sequelize = require('../../models').sequelize;
-var VoiceQueue = require('../../models').VoiceQueue;
-var ReportMember = require('../../models').ReportMember;
-var UserHasVoiceQueue = require('../../models').UserHasVoiceQueue;
-var UserHasChatQueue = require('../../models').UserHasChatQueue;
-var UserHasMailQueue = require('../../models').UserHasMailQueue;
-var UserHasFaxQueue = require('../../models').UserHasFaxQueue;
-var UserHasSmsQueue = require('../../models').UserHasSmsQueue;
-var UserHasOpenchannelQueue = require('../../models').UserHasOpenchannelQueue;
-
-function Action(ami) {
+const moment = require('moment');
+const util = require('util');
+const Promise = require('bluebird');
+
+const config = require('../environment');
+const Agent = require('../../models').User;
+const Sequelize = require('../../models').sequelize;
+const VoiceQueue = require('../../models').VoiceQueue;
+const ReportMember = require('../../models').ReportMember;
+const UserHasVoiceQueue = require('../../models').UserHasVoiceQueue;
+const UserHasChatQueue = require('../../models').UserHasChatQueue;
+const UserHasMailQueue = require('../../models').UserHasMailQueue;
+const UserHasFaxQueue = require('../../models').UserHasFaxQueue;
+const UserHasSmsQueue = require('../../models').UserHasSmsQueue;
+const UserHasOpenchannelQueue = require('../../models').UserHasOpenchannelQueue;
+
+function Action(ami, io) {
   console.log('Action Initialization...');
   var channels = ['voice', 'chat', 'mail', 'fax', 'sms', 'openchannel'];
 
+  Agent.afterUpdate(function(doc, options) {
+    io.to(util.format('%s:%s', doc.role, doc.id)).emit('agent:save', {
+      id: doc.id,
+      online: doc.online,
+      queueStatus: doc.queueStatus,
+      queueStatusAt: doc.queueStatusAt,
+      voicePause: doc.voicePause,
+      chatPause: doc.chatPause,
+      mailPause: doc.mailPause,
+      faxPause: doc.faxPause,
+      smsPause: doc.smsPause,
+      openchannelPause: doc.openchannelPause,
+      lastPauseAt: doc.lastPauseAt
+    });
+  });
+
   process.on('message', function(data) {
     switch (data.evt) {
       case 'Action.afterCreate':
-        return onSave(data, null, ami);
+        return onSave(data, data.options, ami);
 
       case 'ReportMember.beforeCreate':
         return ReportMember
@@ -158,7 +175,9 @@ function Action(ami) {
   // HANDLE UNPAUSE FUNCTION
   function handleUnpause(options, action) {
     return function(agent) {
-      if (!options.body) options.body = {};
+      if (!options.body) {
+        options.body = {}
+      }
 
       switch (options.body.channel) {
         case 'voice':
@@ -407,7 +426,8 @@ function Action(ami) {
                   membername: agent.name,
                   UserId: agent.id,
                 },
-                transaction: options.transaction || null
+                transaction: options.transaction || null,
+                individualHooks: true
               }));
           });
           return Promise
@@ -720,4 +740,8 @@ function Action(ami) {
   return {};
 }
 
+// SOCKET IO CHILD CONNETION
+
+
+
 module.exports = Action;
diff --git a/server/config/ami/acw.js b/server/config/ami/acw.js
index 22c0465..2799028 100644
--- a/server/config/ami/acw.js
+++ b/server/config/ami/acw.js
@@ -18,7 +18,7 @@ function ACW(ami) {
     .findAll()
     .then(function(voiceQueues) {
       _voiceQueues = voiceQueues;
-      // console.log('_voiceQueues', _.map(_voiceQueues, 'dataValues'));
+
       synchCollection(VoiceQueue, _voiceQueues, 'name');
       return Agent
         .scope('agent')
@@ -26,12 +26,12 @@ function ACW(ami) {
     })
     .then(function(agents) {
       _agents = agents;
-      // console.log('_agents', _.map(_agents, 'dataValues'));
+
       synchCollection(Agent, _agents, 'id');
 
-      // emitter.on(util.format('%s.%s', 'Action', 'afterDestroy'), function(doc, options) {
-      //   return onSave(doc, options);
-      // });
+      Action.afterDestroy(function(doc, options) {
+        return onSave(doc, options);
+      });
     })
     .catch(function(err) {
       console.log(err);
diff --git a/server/config/ami/ami.js b/server/config/ami/ami.js
index 197f842..3724878 100644
--- a/server/config/ami/ami.js
+++ b/server/config/ami/ami.js
@@ -37,6 +37,11 @@ var ami = require('asterisk-manager')(config.asterisk.port,
 
 ami.keepConnected();
 
+var io = require('socket.io-emitter')({
+  host: config.ip,
+  port: 6379
+});
+
 var agent = new Agent();
 var call = new Call();
 var member = new Member();
@@ -45,7 +50,7 @@ var queuecaller = new QueueCaller();
 var recording = new Recording();
 var trunk = new Trunk(ami);
 var context = new Context(ami);
-var action = new Action(ami);
+var action = new Action(ami, io);
 var acw = new ACW(ami);
 var user = new User();
 var tranfer = new Transfer();
@@ -226,7 +231,9 @@ ami.on('attendedtransfer', function(evt) {
 
 // Variable Events
 ami.on('varset', function(evt) {
-  // console.log(evt);
+  evt.evt = evt.event;
+  process.send(evt);
+
   var event = getVariable(evt);
   switch (event.variable) {
     case 'mixmonitor_filename':
diff --git a/server/config/ami/index.js b/server/config/ami/index.js
index 4f1f74d..7a7d20f 100644
--- a/server/config/ami/index.js
+++ b/server/config/ami/index.js
@@ -3,6 +3,25 @@
 const path = require('path');
 const cp = require('child_process');
 
+const config = require('../environment');
+const User = require('../../models').User;
+const Action = require('../../models').Action;
+const ReportMember = require('../../models').ReportMember;
+
 var cpAmi = cp.fork(path.join(__dirname, 'ami'));
 
+Action.afterCreate(function(doc, options) {
+  doc.dataValues.evt = 'Action.afterCreate';
+  doc.dataValues.options = {
+    body: options.body || null
+  };
+
+  cpAmi.send(doc.dataValues);
+});
+
+ReportMember.afterCreate(function(doc, options) {
+  doc.dataValues.evt = 'ReportMember.beforeCreate';
+  cpAmi.send(doc.dataValues);
+});
+
 module.exports = cpAmi;
diff --git a/server/config/ami/network.js b/server/config/ami/network.js
index 361eccc..dcf1246 100644
--- a/server/config/ami/network.js
+++ b/server/config/ami/network.js
@@ -11,17 +11,17 @@ var config = require('../../config/environment');
 function Network(ami) {
   console.log('Network Initialization...');
 
-  // emitter.on('Network.afterCreate', function(doc) {
-  //   networkRewrite(doc, ami);
-  // });
-  //
-  // emitter.on('Network.afterUpdate', function(doc) {
-  //   networkRewrite(doc, ami);
-  // });
-  //
-  // emitter.on('Network.afterDelete', function(doc) {
-  //   networkRewrite(doc, ami);
-  // });
+  NetwokModel.afterCreate(function(doc) {
+    networkRewrite(doc, ami);
+  });
+
+  NetwokModel.afterUpdate(function(doc) {
+    networkRewrite(doc, ami);
+  });
+
+  NetwokModel.afterDestroy(function(doc) {
+    networkRewrite(doc, ami);
+  });
 }
 
 function networkRewrite(doc, ami) {
diff --git a/server/config/ami/queue_caller.js b/server/config/ami/queue_caller.js
index 7abefef..6a1a4af 100644
--- a/server/config/ami/queue_caller.js
+++ b/server/config/ami/queue_caller.js
@@ -76,7 +76,6 @@ function findAndUpdate(evt) {
     });
 }
 
-
 ReportQueue.afterCreate(function(doc, options) {
   doc.dataValues.evt = 'ReportQueue.afterCreate';
   process.send(doc.dataValues);
diff --git a/server/config/ami/queue_member.js b/server/config/ami/queue_member.js
index 45831e4..dafa42e 100644
--- a/server/config/ami/queue_member.js
+++ b/server/config/ami/queue_member.js
@@ -1,5 +1,8 @@
-var moment = require('moment');
-var UserHasVoiceQueue = require('../../models').UserHasVoiceQueue;
+'use strict';
+
+const _ = require('lodash');
+const moment = require('moment');
+const UserHasVoiceQueue = require('../../models').UserHasVoiceQueue;
 
 function QueueMember() {
   console.log('QueueMember Initialization...');
@@ -32,25 +35,46 @@ QueueMember.prototype.ringinuse = function(evt) {
 }
 
 QueueMember.prototype.status = function(evt) {
-  return findAndUpdate(evt);
+  // return findAndUpdate(evt);
 }
 
 function findAndUpdate(evt, options) {
-  // return UserHasVoiceQueue
-  //   .update(evt, {
-  //     where: {
-  //       queue: evt.queue,
-  //       membername: evt.membername
-  //     },
-  //     individualHooks: true,
-  //     raw: true
-  //   })
-  //   .then(function() {
-  //     console.log('[queuemember] update member');
-  //   })
-  //   .catch(function(err) {
-  //     console.error('[queuemember] update member error: ' + err);
-  //   });
+  return UserHasVoiceQueue
+    .update(evt, {
+      where: {
+        queue: evt.queue,
+        membername: evt.membername
+      },
+      individualHooks: true,
+      raw: true
+    })
+    .then(function() {
+      console.log('[queuemember] update member');
+    })
+    .catch(function(err) {
+      console.error('[queuemember] update member error: ' + err);
+    });
 }
 
+UserHasVoiceQueue.afterCreate(function(doc, options) {
+  doc.dataValues.evt = 'UserHasVoiceQueue.afterCreate';
+  process.send(doc.dataValues);
+});
+
+UserHasVoiceQueue.afterBulkCreate(function(doc, options) {
+  doc.dataValues.evt = 'UserHasVoiceQueue.afterBulkCreate';
+  process.send(doc.dataValues);
+});
+
+UserHasVoiceQueue.afterBulkDestroy(function(doc, options) {
+  doc.dataValues.evt = 'UserHasVoiceQueue.afterBulkDestroy';
+  process.send(doc.dataValues);
+});
+
+UserHasVoiceQueue.afterUpdate(function(doc, options) {
+  doc.dataValues.evt = 'UserHasVoiceQueue.afterUpdate';
+  doc.dataValues.changed = _.keyBy(doc.changed());
+  process.send(doc.dataValues);
+});
+
 module.exports = QueueMember;
diff --git a/server/config/ami/recording.js b/server/config/ami/recording.js
index 2162be6..873d66d 100644
--- a/server/config/ami/recording.js
+++ b/server/config/ami/recording.js
@@ -1,4 +1,7 @@
-var VoiceRecording = require('../../models').VoiceRecording;
+'use strict';
+
+const _ = require('lodash');
+const VoiceRecording = require('../../models').VoiceRecording;
 
 function Recording() {
   console.log('Recording Initialization...');
@@ -37,7 +40,8 @@ function updateQueue(evt) {
       where: {
         uniqueid: evt.uniqueid
       },
-      raw: true
+      raw: true,
+      individualHooks: true
     })
     .catch(function(err) {
       console.error('Recording queue update error:', err);
@@ -55,6 +59,7 @@ function updateType(evt) {
       if (recording) {
         recording.type = evt.type;
         recording.customerPhone = evt.type === 'outbound' ? recording.exten : recording.calleridnum;
+
         return recording
           .save();
       }
@@ -64,4 +69,15 @@ function updateType(evt) {
     });
 }
 
+VoiceRecording.afterCreate(function(doc, options) {
+  doc.dataValues.evt = 'VoiceRecording.afterCreate';
+  process.send(doc.dataValues);
+});
+
+VoiceRecording.afterUpdate(function(doc, options) {
+  doc.dataValues.evt = 'VoiceRecording.afterUpdate';
+  doc.dataValues.changed = _.keyBy(doc.changed());
+  process.send(doc.dataValues);
+});
+
 module.exports = Recording;
diff --git a/server/config/automations/chat.js b/server/config/automations/chat.js
index bf45b45..a874ea6 100644
--- a/server/config/automations/chat.js
+++ b/server/config/automations/chat.js
@@ -5,11 +5,10 @@ var moment = require('moment');
 
 var Automation = require('../../models').Automation;
 var ChatRoom = require('../../models').ChatRoom;
-var automationTimeout;
 var activeChatAutomations = {};
 
 function executeAutomation(id) {
-  console.log('Executing Chat Automation ', id);
+  console.log('[Automation] Executing Chat', id);
   var _chatAutomation;
   return Automation
     .scope('all')
@@ -52,7 +51,9 @@ function executeAutomation(id) {
       });
     })
     .catch(function(err) {
-      console.log('Chat Automation exec error', err);
+      console.error('[Automation] Error in Chat exec');
+      console.error('[Automation] Message:', err.message);
+      console.error('[Automation] Stack:', err.stack);
     });
 }
 
@@ -65,7 +66,9 @@ function setStatus(ticketId, newStatus) {
       }
     })
     .catch(function(err) {
-      console.log('Automatic chat status error', err);
+      console.error('[Automation] Error in Mail setStatus');
+      console.error('[Automation] Message:', err.message);
+      console.error('[Automation] Stack:', err.stack);
     });
 }
 
@@ -117,7 +120,7 @@ function getCondition(condition) {
 }
 
 function createInterval(chatAutomation) {
-  console.log('Chat Automation ', chatAutomation.id, ' set with timeout ', chatAutomation.timeout * 60 * 1000);
+  console.log('[Automation] Mail', chatAutomation.id, 'set with timeout', chatAutomation.timeout * 60 * 1000);
   activeChatAutomations['interval' + chatAutomation.id] = setInterval(function() {
     executeAutomation(chatAutomation.id);
   }, chatAutomation.timeout * 60 * 1000);
@@ -125,31 +128,39 @@ function createInterval(chatAutomation) {
 
 module.exports = function() {
 
+  console.log('[Automation] Chat service started');
+
   Automation.afterCreate(function(doc, options) {
-    console.log('Chat Automation ', doc.id, ' created, the status is ', doc.status);
-    if (doc.status && doc.channel === 'chat') {
-      createInterval(doc);
+    if (doc.channel === 'chat') {
+      console.log('[Automation] Chat', doc.id, 'created, the status is', doc.status);
+      if (doc.status) {
+        createInterval(doc);
+      }
     }
   });
 
   Automation.afterUpdate(function(doc, options) {
-    console.log('Chat Automation ', doc.id, ' updated, the status is ', doc.status);
-    if (activeChatAutomations['interval' + doc.id]) {
-      console.log('Chat automation unset ', doc.id);
-      clearInterval(activeChatAutomations['interval' + doc.id]);
-      delete activeChatAutomations['interval' + doc.id];
-    }
-    if (doc.status && doc.channel === 'chat') {
-      createInterval(doc);
+    if (doc.channel === 'chat') {
+      console.log('[Automation] Chat', doc.id, 'updated, the status is', doc.status);
+      if (activeChatAutomations['interval' + doc.id]) {
+        console.log('[Automation] Chat unset ', doc.id);
+        clearInterval(activeChatAutomations['interval' + doc.id]);
+        delete activeChatAutomations['interval' + doc.id];
+      }
+      if (doc.status) {
+        createInterval(doc);
+      }
     }
   });
 
   Automation.afterDelete(function(doc, options) {
-    console.log('Chat Automation ', doc.id, ' deleted');
-    if (activeChatAutomations['interval' + doc.id]) {
-      console.log('Chat automation unset ', doc.id);
-      clearInterval(activeChatAutomations['interval' + doc.id]);
-      delete activeChatAutomations['interval' + doc.id];
+    if (doc.channel === 'chat') {
+      console.log('[Automation] Chat', doc.id, ' deleted');
+      if (activeChatAutomations['interval' + doc.id]) {
+        console.log('[Automation] Chat unset ', doc.id);
+        clearInterval(activeChatAutomations['interval' + doc.id]);
+        delete activeChatAutomations['interval' + doc.id];
+      }
     }
   });
 
@@ -164,11 +175,16 @@ module.exports = function() {
     })
     .then(function(chatAutomations) {
 
+      console.log('[Automation] Chat are', chatAutomations.length);
+
       chatAutomations.forEach(function(chatAutomation) {
         createInterval(chatAutomation);
       });
+
     })
     .catch(function(err) {
-      console.log('Chat Automation init error', err);
+      console.error('[Automation] Error in Chat init');
+      console.error('[Automation] Message:', err.message);
+      console.error('[Automation] Stack:', err.stack);
     });
 };
diff --git a/server/config/automations/fax.js b/server/config/automations/fax.js
index e7f0b74..d69bba5 100644
--- a/server/config/automations/fax.js
+++ b/server/config/automations/fax.js
@@ -1,18 +1,14 @@
 'use strict';
 
 var _ = require('lodash');
-var config = require('../environment');
 var moment = require('moment');
-// var stringifyObject = require('stringify-object');
 
-var sequelize = require('../../models').sequelize;
 var Automation = require('../../models').Automation;
 var FaxRoom = require('../../models').FaxRoom;
-var automationTimeout;
 var activeFaxAutomations = {};
 
 function executeAutomation(id) {
-  console.log('Executing Mail Automation ', id);
+  console.log('[Automation] Executing Fax', id);
   var _faxAutomation;
   return Automation
     .scope('all')
@@ -56,7 +52,9 @@ function executeAutomation(id) {
       });
     })
     .catch(function(err) {
-      console.log('Fax Automation exec error', err);
+      console.error('[Automation] Error in Fax exec');
+      console.error('[Automation] Message:', err.message);
+      console.error('[Automation] Stack:', err.stack);
     });
 }
 
@@ -69,7 +67,9 @@ function setStatus(ticketId, newStatus) {
       }
     })
     .catch(function(err) {
-      console.log('Automatic mail status error', err);
+      console.error('[Automation] Error in Fax setStatus');
+      console.error('[Automation] Message:', err.message);
+      console.error('[Automation] Stack:', err.stack);
     });
 }
 
@@ -121,7 +121,7 @@ function getCondition(condition) {
 }
 
 function createInterval(faxAutomation) {
-  console.log('Fax Automation ', faxAutomation.id, ' set with timeout ', faxAutomation.timeout * 60 * 1000);
+  console.log('[Automation] Mail', faxAutomation.id, 'set with timeout', faxAutomation.timeout * 60 * 1000);
   activeFaxAutomations['interval' + faxAutomation.id] = setInterval(function() {
     executeAutomation(faxAutomation.id);
   }, faxAutomation.timeout * 60 * 1000);
@@ -129,31 +129,39 @@ function createInterval(faxAutomation) {
 
 module.exports = function() {
 
+  console.log('[Automation] Fax service started');
+
   Automation.afterCreate(function(doc, options) {
-    console.log('Fax Automation ', doc.id, ' created, the status is ', doc.status);
-    if (doc.status && doc.channel === 'fax') {
-      createInterval(doc);
+    if (doc.channel === 'fax') {
+      console.log('[Automation] Fax', doc.id, 'created, the status is', doc.status);
+      if (doc.status) {
+        createInterval(doc);
+      }
     }
   });
 
   Automation.afterUpdate(function(doc, options) {
-    console.log('Fax Automation ', doc.id, ' updated, the status is ', doc.status);
-    if (activeFaxAutomations['interval' + doc.id]) {
-      console.log('Fax automation unset ', doc.id);
-      clearInterval(activeFaxAutomations['interval' + doc.id]);
-      delete activeFaxAutomations['interval' + doc.id];
-    }
-    if (doc.status && doc.channel === 'fax') {
-      createInterval(doc);
+    if (doc.channel === 'fax') {
+      console.log('[Automation] Fax', doc.id, 'updated, the status is', doc.status);
+      if (activeFaxAutomations['interval' + doc.id]) {
+        console.log('[Automation] Fax unset ', doc.id);
+        clearInterval(activeFaxAutomations['interval' + doc.id]);
+        delete activeFaxAutomations['interval' + doc.id];
+      }
+      if (doc.status) {
+        createInterval(doc);
+      }
     }
   });
 
   Automation.afterDelete(function(doc, options) {
-    console.log('Fax Automation ', doc.id, ' deleted');
-    if (activeFaxAutomations['interval' + doc.id]) {
-      console.log('Fax automation unset ', doc.id);
-      clearInterval(activeFaxAutomations['interval' + doc.id]);
-      delete activeFaxAutomations['interval' + doc.id];
+    if (doc.channel === 'fax') {
+      console.log('[Automation] Fax', doc.id, ' deleted');
+      if (activeFaxAutomations['interval' + doc.id]) {
+        console.log('[Automation] Fax unset ', doc.id);
+        clearInterval(activeFaxAutomations['interval' + doc.id]);
+        delete activeFaxAutomations['interval' + doc.id];
+      }
     }
   });
 
@@ -168,11 +176,16 @@ module.exports = function() {
     })
     .then(function(faxAutomations) {
 
+      console.log('[Automation] Fax are', faxAutomations.length);
+
       faxAutomations.forEach(function(faxAutomation) {
         createInterval(faxAutomation);
       });
+
     })
     .catch(function(err) {
-      console.log('Fax Automation init error', err);
+      console.error('[Automation] Error in Mail init');
+      console.error('[Automation] Message:', err.message);
+      console.error('[Automation] Stack:', err.stack);
     });
 };
diff --git a/server/config/automations/mail.js b/server/config/automations/mail.js
index 14f8d17..ec240d2 100644
--- a/server/config/automations/mail.js
+++ b/server/config/automations/mail.js
@@ -1,17 +1,14 @@
 'use strict';
 
 var _ = require('lodash');
-var config = require('../environment');
 var moment = require('moment');
-// var stringifyObject = require('stringify-object');
 
-var sequelize = require('../../models').sequelize;
 var Automation = require('../../models').Automation;
 var MailRoom = require('../../models').MailRoom;
 var activeMailAutomations = {};
 
 function executeAutomation(id) {
-  console.log('Executing Mail Automation ', id);
+  console.log('[Automation] Executing Mail', id);
   var _mailAutomation;
   return Automation
     .scope('all')
@@ -55,7 +52,9 @@ function executeAutomation(id) {
       });
     })
     .catch(function(err) {
-      console.log('Mail Automation exec error', err);
+      console.error('[Automation] Error in Mail exec');
+      console.error('[Automation] Message:', err.message);
+      console.error('[Automation] Stack:', err.stack);
     });
 }
 
@@ -68,7 +67,9 @@ function setStatus(ticketId, newStatus) {
       }
     })
     .catch(function(err) {
-      console.log('Automatic mail status error', err);
+      console.error('[Automation] Error in Mail setStatus');
+      console.error('[Automation] Message:', err.message);
+      console.error('[Automation] Stack:', err.stack);
     });
 }
 
@@ -120,7 +121,7 @@ function getCondition(condition) {
 }
 
 function createInterval(mailAutomation) {
-  console.log('Mail Automation ', mailAutomation.id, ' set with timeout ', mailAutomation.timeout * 60 * 1000);
+  console.log('[Automation] Mail', mailAutomation.id, 'set with timeout', mailAutomation.timeout * 60 * 1000);
   activeMailAutomations['interval' + mailAutomation.id] = setInterval(function() {
     executeAutomation(mailAutomation.id);
   }, mailAutomation.timeout * 60 * 1000);
@@ -128,31 +129,39 @@ function createInterval(mailAutomation) {
 
 module.exports = function() {
 
+  console.log('[Automation] Mail service started');
+
   Automation.afterCreate(function(doc, options) {
-    console.log('Mail Automation ', doc.id, ' created, the status is ', doc.status);
-    if (doc.status && doc.channel === 'mail') {
-      createInterval(doc);
+    if (doc.channel === 'mail') {
+      console.log('[Automation] Mail', doc.id, 'created, the status is', doc.status);
+      if (doc.status) {
+        createInterval(doc);
+      }
     }
   });
 
   Automation.afterUpdate(function(doc, options) {
-    console.log('Mail Automation ', doc.id, ' updated, the status is ', doc.status);
-    if (activeMailAutomations['interval' + doc.id]) {
-      console.log('Mail automation unset ', doc.id);
-      clearInterval(activeMailAutomations['interval' + doc.id]);
-      delete activeMailAutomations['interval' + doc.id];
-    }
-    if (doc.status && doc.channel === 'mail') {
-      createInterval(doc);
+    if (doc.channel === 'mail') {
+      console.log('[Automation] Mail', doc.id, 'updated, the status is', doc.status);
+      if (activeMailAutomations['interval' + doc.id]) {
+        console.log('[Automation] Mail unset ', doc.id);
+        clearInterval(activeMailAutomations['interval' + doc.id]);
+        delete activeMailAutomations['interval' + doc.id];
+      }
+      if (doc.status) {
+        createInterval(doc);
+      }
     }
   });
 
-  Automation.afterDelete(function(doc, options) {
-    console.log('Mail Automation ', doc.id, ' deleted');
-    if (activeMailAutomations['interval' + doc.id]) {
-      console.log('Mail automation unset ', doc.id);
-      clearInterval(activeMailAutomations['interval' + doc.id]);
-      delete activeMailAutomations['interval' + doc.id];
+  Automation.afterDestroy(function(doc, options) {
+    if (doc.channel === 'mail') {
+      console.log('[Automation] Mail', doc.id, ' deleted');
+      if (activeMailAutomations['interval' + doc.id]) {
+        console.log('[Automation] Mail unset ', doc.id);
+        clearInterval(activeMailAutomations['interval' + doc.id]);
+        delete activeMailAutomations['interval' + doc.id];
+      }
     }
   });
 
@@ -167,11 +176,16 @@ module.exports = function() {
     })
     .then(function(mailAutomations) {
 
+      console.log('[Automation] Mail are', mailAutomations.length);
+
       mailAutomations.forEach(function(mailAutomation) {
         createInterval(mailAutomation);
       });
+
     })
     .catch(function(err) {
-      console.log('Mail Automation init error', err);
+      console.error('[Automation] Error in Mail init');
+      console.error('[Automation] Message:', err.message);
+      console.error('[Automation] Stack:', err.stack);
     });
 };
diff --git a/server/config/integrations/index.js b/server/config/integrations/index.js
index 1fa5f58..60ec65f 100644
--- a/server/config/integrations/index.js
+++ b/server/config/integrations/index.js
@@ -12,7 +12,7 @@ var Motionbar = require('./motionbar');
 // Variables
 var MAX_CALLS = 200;
 
-function Integration(ami) {
+function Integration() {
   console.log('Trigger Integration Initialization...');
 
   var zendesk = new Zendesk();
diff --git a/server/config/triggers/index.js b/server/config/triggers/index.js
index 125a065..572f74f 100644
--- a/server/config/triggers/index.js
+++ b/server/config/triggers/index.js
@@ -33,7 +33,7 @@ var MAX_CALLS = 200;
 var callChannels = []; //array of calls
 var localVariables = [];
 
-module.exports = function(ami) {
+module.exports = function(cpAmi) {
 
   var util = new Util();
   var voice = new Voice();
@@ -42,7 +42,7 @@ module.exports = function(ami) {
   var sms = new Sms();
   var cm = new Cm();
   var jscripty = new Jscripty();
-  var integration = new Integration(ami);
+  var integration = new Integration();
   var urlForward = new UrlForward();
   var _triggers = [];
   Trigger
@@ -53,7 +53,7 @@ module.exports = function(ami) {
       return synchTriggers(_triggers);
     })
     .then(function() {
-      return synchVars(ami);
+      return synchVars(cpAmi);
     })
     .then(function() {
       console.log('Triggers are ', _triggers.length);
@@ -120,8 +120,7 @@ module.exports = function(ami) {
     });
 }
 
-function synchVars(ami) {
-
+function synchVars(cpAmi) {
   return Variable
     .findAll()
     .then(function(variables) {
@@ -129,27 +128,29 @@ function synchVars(ami) {
       return synchVariables(localVariables);
     })
     .then(function() {
-      ami.on('varset', function(evt) {
-        if (evt.hasOwnProperty('variable') && evt.hasOwnProperty('value')) {
-          var foundVar = _.find(localVariables, function(variable) { //search varset variable in local db variables
-            return (variable.name === _.head(_.keys(evt.variable))) || (_.toLower(variable.name) === _.head(_.keys(evt.variable)));
-          });
-          if (foundVar) { //if local db variable exist
-            var callFound = _.find(callChannels, {
-              uniqueid: evt.uniqueid
-            }); //check if there is already an object relative to the call, where the variable has been set, in the calls array
-            if (callFound) { //if the call exist, I add the new variable to the list of the call variables or update the old value
-              callFound.variables[foundVar.name] = evt.value;
-            } else { //otherwise
-              if (callChannels.length >= MAX_CALLS) { //If I exceed the max lenght of the calls array I pop the oldest element (FIFO)
-                callChannels.shift();
+      cpAmi.on('message', function(data) {
+        if (data.evt === 'varset') {
+          if (data.hasOwnProperty('variable') && data.hasOwnProperty('value')) {
+            var foundVar = _.find(localVariables, function(variable) { //search varset variable in local db variables
+              return (variable.name === _.head(_.keys(data.variable))) || (_.toLower(variable.name) === _.head(_.keys(data.variable)));
+            });
+            if (foundVar) { //if local db variable exist
+              var callFound = _.find(callChannels, {
+                uniqueid: data.uniqueid
+              }); //check if there is already an object relative to the call, where the variable has been set, in the calls array
+              if (callFound) { //if the call exist, I add the new variable to the list of the call variables or update the old value
+                callFound.variables[foundVar.name] = data.value;
+              } else { //otherwise
+                if (callChannels.length >= MAX_CALLS) { //If I exceed the max lenght of the calls array I pop the oldest element (FIFO)
+                  callChannels.shift();
+                }
+                var call = {
+                  uniqueid: data.uniqueid,
+                  variables: {}
+                };
+                call.variables[foundVar.name] = data.value;
+                callChannels.push(call); //Insert the new call in the calls array
               }
-              var call = {
-                uniqueid: evt.uniqueid,
-                variables: {}
-              };
-              call.variables[foundVar.name] = evt.value;
-              callChannels.push(call); //Insert the new call in the calls array
             }
           }
         }
@@ -189,7 +190,6 @@ function getActionVariables(doc, channel) {
   }
 }
 
-
 function execActions(actions, doc, channel, subtype, util, voice, mail, cm, jscripty, integration, urlForward, chat, sms) {
   console.log('execActions');
   actions.forEach(function(action) {
diff --git a/server/models/action.js b/server/models/action.js
index 3e20e34..b19921c 100644
--- a/server/models/action.js
+++ b/server/models/action.js
@@ -1,9 +1,6 @@
 'use strict';
 
-var emitter = require('cluster-emitter');
-
 module.exports = function(sequelize, DataTypes) {
-
 	var Action = sequelize.define('Action', {
 		name: DataTypes.STRING,
 		data1: DataTypes.STRING,
@@ -12,14 +9,7 @@ module.exports = function(sequelize, DataTypes) {
 		data4: DataTypes.STRING,
 		data5: DataTypes.STRING
 	}, {
-		tableName: 'actions',
-		hooks: {
-			afterCreate: function(doc, options) {
-				emitter.to(['master']).emit('Action.afterCreate', doc, {
-					body: options.body
-				});
-			}
-		}
+		tableName: 'actions'
 	});
 
 	return Action;
diff --git a/server/models/chat_room.js b/server/models/chat_room.js
index 48d6f74..6c48356 100644
--- a/server/models/chat_room.js
+++ b/server/models/chat_room.js
@@ -1,7 +1,5 @@
 'use strict';
 
-const emitter = require('cluster-emitter');
-
 module.exports = function(sequelize, DataTypes) {
 
 	var ChatRoom = sequelize.define('ChatRoom', {
@@ -69,21 +67,6 @@ module.exports = function(sequelize, DataTypes) {
 					}]
 				}
 			});
-		},
-		hooks: {
-			afterCreate: function(doc, options) {
-				emitter.to(['master']).emit('ChatRoom.afterCreate', doc, {
-					body: options.body
-				});
-			},
-			afterUpdate: function(doc, options) {
-				emitter.to(['master']).emit('ChatRoom.afterUpdate', doc, {
-					changed: doc.changed()
-				});
-			},
-			afterDestroy: function(doc, options) {
-				emitter.to(['master']).emit('ChatRoom.afterDestroy', doc);
-			}
 		}
 	});
 
diff --git a/server/models/chat_website.js b/server/models/chat_website.js
index 0da4052..310ec96 100644
--- a/server/models/chat_website.js
+++ b/server/models/chat_website.js
@@ -2,8 +2,6 @@
  * Chat Website Model
  */
 
-var emitter = require('cluster-emitter');
-
 module.exports = function(sequelize, DataTypes) {
 
 	var ChatWebsite = sequelize.define('ChatWebsite', {
@@ -176,17 +174,6 @@ module.exports = function(sequelize, DataTypes) {
 		}
 	}, {
 		tableName: 'chat_websites',
-		hooks: {
-			afterCreate: function(doc, options) {
-				emitter.to(['master']).emit('ChatWebsite.afterUpdate', doc);
-			},
-			afterUpdate: function(doc, options) {
-				emitter.to(['master']).emit('ChatWebsite.afterUpdate', doc);
-			},
-			afterDestroy: function(doc, options) {
-				emitter.to(['master']).emit('ChatWebsite.afterDestroy', doc);
-			}
-		},
 		associate: function(models) {
 			// hasMany relations
 			ChatWebsite.belongsTo(models.Template, {
diff --git a/server/models/fax_account.js b/server/models/fax_account.js
index c0f8d39..0c47fad 100644
--- a/server/models/fax_account.js
+++ b/server/models/fax_account.js
@@ -1,8 +1,5 @@
 'use strict';
 
-const crypto = require('crypto');
-const emitter = require('cluster-emitter');
-
 module.exports = function(sequelize, DataTypes) {
 
 	var FaxAccount = sequelize.define('FaxAccount', {
@@ -127,19 +124,6 @@ module.exports = function(sequelize, DataTypes) {
 					}]
 				}]
 			});
-		},
-		hooks: {
-			afterCreate: function(doc, options) {
-				emitter.to(['master']).emit('FaxAccount.afterCreate', doc, {
-					body: options.body
-				});
-			},
-			afterUpdate: function(doc, options) {
-				emitter.to(['master']).emit('FaxAccount.afterUpdate', doc);
-			},
-			afterDestroy: function(doc, options) {
-				emitter.to(['master']).emit('FaxAccount.afterDestroy', doc);
-			}
 		}
 	});
 
diff --git a/server/models/fax_message.js b/server/models/fax_message.js
index 1abe44a..1b43851 100644
--- a/server/models/fax_message.js
+++ b/server/models/fax_message.js
@@ -1,7 +1,6 @@
 'use strict';
 
 const _ = require('lodash');
-const emitter = require('cluster-emitter');
 
 module.exports = function(sequelize, DataTypes) {
 
@@ -59,21 +58,6 @@ module.exports = function(sequelize, DataTypes) {
 			});
 			FaxMessage.belongsTo(models.User);
 			FaxMessage.hasMany(models.FaxAttachment);
-		},
-		hooks: {
-			afterCreate: function(doc, options) {
-				emitter.to(['master']).emit('FaxMessage.afterCreate', doc, {
-					body: options.body
-				});
-			},
-			afterUpdate: function(doc, options) {
-				emitter.to(['master']).emit('FaxMessage.afterUpdate', doc, {
-					changed: doc.changed()
-				});
-			},
-			afterDestroy: function(doc, options) {
-				emitter.to(['master']).emit('FaxMessage.afterDestroy', doc);
-			}
 		}
 	});
 
diff --git a/server/models/fax_room.js b/server/models/fax_room.js
index 41caec9..a2e257e 100644
--- a/server/models/fax_room.js
+++ b/server/models/fax_room.js
@@ -2,9 +2,7 @@
  * Fax Room Model
  */
 
-const crypto = require('crypto');
 const moment = require('moment');
-const emitter = require('cluster-emitter');
 
 module.exports = function(sequelize, DataTypes) {
 
@@ -75,22 +73,6 @@ module.exports = function(sequelize, DataTypes) {
     }
   }, {
     tableName: 'fax_rooms',
-    hooks: {
-      afterCreate: function(doc, options) {
-        emitter.to(['master']).emit('FaxRoom.afterCreate', doc, {
-          user: options.user
-        });
-      },
-      afterUpdate: function(doc, options) {
-        emitter.to(['master']).emit('FaxRoom.afterUpdate', doc, {
-          changed: doc.changed(),
-          user: options.user
-        });
-      },
-      afterDestroy: function(doc) {
-        emitter.to(['master']).emit('FaxRoom.afterDestroy', doc);
-      }
-    },
     paranoid: true,
     associate: function(models) {
       // hasMany relations
diff --git a/server/models/mail_account.js b/server/models/mail_account.js
index 18e597a..94efd99 100644
--- a/server/models/mail_account.js
+++ b/server/models/mail_account.js
@@ -1,7 +1,6 @@
 'use strict';
 
 const _ = require('lodash');
-const emitter = require('cluster-emitter');
 
 module.exports = function(sequelize, DataTypes) {
 	var MailAccount = sequelize.define('MailAccount', {
@@ -117,21 +116,6 @@ module.exports = function(sequelize, DataTypes) {
 					}]
 				}]
 			});
-		},
-		hooks: {
-			afterCreate: function(doc, options) {
-				emitter.to(['master']).emit('MailAccount.afterCreate', doc, {
-					body: options.body
-				});
-			},
-			afterUpdate: function(doc, options) {
-				emitter.to(['master']).emit('MailAccount.afterUpdate', doc, {
-					changed: doc.changed()
-				});
-			},
-			afterDestroy: function(doc, options) {
-				emitter.to(['master']).emit('MailAccount.afterDestroy', doc);
-			}
 		}
 	});
 
diff --git a/server/models/mail_message.js b/server/models/mail_message.js
index f32d4cf..20a9d5d 100644
--- a/server/models/mail_message.js
+++ b/server/models/mail_message.js
@@ -3,7 +3,6 @@
  */
 
 var _ = require('lodash');
-var emitter = require('cluster-emitter');
 
 module.exports = function(sequelize, DataTypes) {
 
@@ -89,19 +88,6 @@ module.exports = function(sequelize, DataTypes) {
 		accountName: DataTypes.STRING
 	}, {
 		tableName: 'mail_messages',
-		hooks: {
-			afterCreate: function(doc) {
-				emitter.to(['master']).emit('MailMessage.afterCreate', doc);
-			},
-			afterUpdate: function(doc) {
-				emitter.to(['master']).emit('MailMessage.afterUpdate', doc, {
-					changed: doc.changed()
-				});
-			},
-			afterDestroy: function(doc) {
-				emitter.to(['master']).emit('MailMessage.afterDestroy', doc);
-			}
-		},
 		paranoid: true,
 		associate: function(models) {
 			MailMessage.hasMany(models.MailAttachment);
diff --git a/server/models/mail_room.js b/server/models/mail_room.js
index adc4743..3e1d176 100644
--- a/server/models/mail_room.js
+++ b/server/models/mail_room.js
@@ -1,6 +1,5 @@
 'use strict';
 
-const emitter = require('cluster-emitter');
 const moment = require('moment');
 const satuses = {
 	NEW: ['OPEN', 'CLOSED'],
@@ -120,24 +119,6 @@ module.exports = function(sequelize, DataTypes) {
 					attributes: ['id', 'name', 'fullname', 'email', 'userpic']
 				}]
 			});
-		},
-		hooks: {
-			afterCreate: function(doc, options) {
-				emitter.to(['master']).emit('MailRoom.afterCreate', doc, {
-					body: options.body,
-					changed: doc.changed(),
-					user: options.user
-				});
-			},
-			afterUpdate: function(doc, options) {
-				emitter.to(['master']).emit('MailRoom.afterUpdate', doc, {
-					changed: doc.changed(),
-					user: options.user
-				});
-			},
-			afterDestroy: function(doc, options) {
-				emitter.to(['master']).emit('MailRoom.afterDestroy', doc);
-			}
 		}
 	});
 
diff --git a/server/models/mail_server_in.js b/server/models/mail_server_in.js
index c1503e3..301037d 100644
--- a/server/models/mail_server_in.js
+++ b/server/models/mail_server_in.js
@@ -1,7 +1,5 @@
 'use strict';
 
-const emitter = require('cluster-emitter');
-
 module.exports = function(sequelize, DataTypes) {
 
 	var MailServerIn = sequelize.define('MailServerIn', {
@@ -62,22 +60,7 @@ module.exports = function(sequelize, DataTypes) {
 			defaultValue: true
 		}
 	}, {
-		tableName: 'mail_servers_in',
-		hooks: {
-			afterCreate: function(doc, options) {
-				emitter.to(['master']).emit('MailServerIn.afterCreate', doc, {
-					body: options.body
-				});
-			},
-			afterUpdate: function(doc, options) {
-				emitter.to(['master']).emit('MailServerIn.afterUpdate', doc, {
-					changed: doc.changed()
-				});
-			},
-			afterDestroy: function(doc, options) {
-				emitter.to(['master']).emit('MailServerIn.afterDestroy', doc);
-			}
-		}
+		tableName: 'mail_servers_in'
 	});
 
 	return MailServerIn;
diff --git a/server/models/mail_server_out.js b/server/models/mail_server_out.js
index 79b53c2..6610fd9 100644
--- a/server/models/mail_server_out.js
+++ b/server/models/mail_server_out.js
@@ -1,7 +1,6 @@
 /**
  *
  */
-var emitter = require('cluster-emitter');
 
 module.exports = function(sequelize, DataTypes) {
 
@@ -24,20 +23,7 @@ module.exports = function(sequelize, DataTypes) {
 		},
 		source: DataTypes.STRING
 	}, {
-		tableName: 'mail_servers_out',
-		hooks: {
-			afterCreate: function(doc) {
-				emitter.to(['master']).emit('MailServerOut.afterCreate', doc);
-			},
-			afterUpdate: function(doc) {
-				emitter.to(['master']).emit('MailServerOut.afterUpdate', doc, {
-					changed: doc.changed()
-				});
-			},
-			afterDestroy: function(doc) {
-				emitter.to(['master']).emit('MailServerOut.afterDestroy', doc);
-			}
-		}
+		tableName: 'mail_servers_out'
 	});
 
 	return MailServerOut;
diff --git a/server/models/network.js b/server/models/network.js
index 64228d9..c370eaf 100644
--- a/server/models/network.js
+++ b/server/models/network.js
@@ -1,7 +1,5 @@
 'use strict';
 
-const emitter = require('cluster-emitter');
-
 module.exports = function(sequelize, DataTypes) {
   var Network = sequelize.define('Network', {
     type: DataTypes.ENUM('localnet', 'externip'),
@@ -19,19 +17,6 @@ module.exports = function(sequelize, DataTypes) {
           type: 'externip'
         }
       }
-    },
-    hooks: {
-      afterCreate: function(doc, options) {
-        emitter.to(['master']).emit('NetWork.afterCreate', doc, {
-          body: options.body
-        });
-      },
-      afterUpdate: function(doc, options) {
-        emitter.to(['master']).emit('NetWork.afterUpdate', doc);
-      },
-      afterDestroy: function(doc, options) {
-        emitter.to(['master']).emit('NetWork.afterDestroy', doc);
-      }
     }
   });
 
diff --git a/server/models/openchannel_room.js b/server/models/openchannel_room.js
index 23e9b29..fe9a279 100644
--- a/server/models/openchannel_room.js
+++ b/server/models/openchannel_room.js
@@ -1,5 +1,4 @@
 const moment = require('moment');
-const emitter = require('cluster-emitter');
 
 module.exports = function(sequelize, DataTypes) {
   var OpenchannelRoom = sequelize.define('OpenchannelRoom', {
@@ -73,14 +72,6 @@ module.exports = function(sequelize, DataTypes) {
     }
   }, {
     tableName: 'openchannel_rooms',
-    hooks: {
-      afterUpdate: function(doc, options) {
-        emitter.to(['master']).emit('OpenchannelRoom.afterUpdate', doc, {
-          changed: doc.changed(),
-          user: options.user
-        });
-      }
-    },
     associate: function(models) {
       // BINDING
       OpenchannelRoom.hasMany(models.OpenchannelRoomStatus, {
diff --git a/server/models/report_agent.js b/server/models/report_agent.js
index 268a27b..f9bd42d 100644
--- a/server/models/report_agent.js
+++ b/server/models/report_agent.js
@@ -2,8 +2,6 @@
  * Agent Log Model
  */
 
-var emitter = require('cluster-emitter');
-
 module.exports = function(sequelize, DataTypes) {
 
   var ReportAgent = sequelize.define('ReportAgent', {
@@ -66,16 +64,6 @@ module.exports = function(sequelize, DataTypes) {
     answeredelsewheremembername: DataTypes.STRING
   }, {
     tableName: 'report_agent',
-    hooks: {
-      afterCreate: function(doc) {
-        emitter.to(['master']).emit('ReportAgent.afterCreate', doc);
-      },
-      afterUpdate: function(doc) {
-        emitter.to(['master']).emit('ReportAgent.afterUpdate', doc, {
-          changed: doc.changed()
-        });
-      }
-    },
     indexes: [{
       fields: ['uniqueid', 'destuniqueid']
     }]
diff --git a/server/models/report_chat.js b/server/models/report_chat.js
index e83d004..7c523a8 100644
--- a/server/models/report_chat.js
+++ b/server/models/report_chat.js
@@ -3,7 +3,6 @@
  */
 
 var moment = require('moment');
-var emitter = require('cluster-emitter');
 
 module.exports = function(sequelize, DataTypes) {
 
@@ -45,14 +44,7 @@ module.exports = function(sequelize, DataTypes) {
     },
     connectedAt: DataTypes.DATE
   }, {
-    tableName: 'report_chat',
-    hooks: {
-      afterUpdate: function(doc, options) {
-        emitter.to(['master']).emit('ReportChat.afterUpdate', doc, {
-          changed: doc.changed()
-        });
-      }
-    }
+    tableName: 'report_chat'
   });
 
   return ReportChat;
diff --git a/server/models/report_chat_session.js b/server/models/report_chat_session.js
index 5372b3f..84520c9 100644
--- a/server/models/report_chat_session.js
+++ b/server/models/report_chat_session.js
@@ -5,7 +5,6 @@
  */
 
 var moment = require('moment');
-const emitter = require('cluster-emitter');
 
 module.exports = function(sequelize, DataTypes) {
 
@@ -44,18 +43,7 @@ module.exports = function(sequelize, DataTypes) {
       defaultValue: 0
     }
   }, {
-    tableName: 'report_chat_session',
-    hooks: {
-      afterCreate: function(doc) {
-        emitter.to(['master']).emit('ReportChatSession.afterCreate', doc);
-      },
-      afterUpdate: function(doc) {
-        emitter.to(['master']).emit('ReportChatSession.afterUpdate', doc);
-      },
-      afterDestroy: function(doc) {
-        emitter.to(['master']).emit('ReportChatSession.afterDestroy', doc);
-      }
-    }
+    tableName: 'report_chat_session'
   });
 
   return ReportChatSession;
diff --git a/server/models/report_dial.js b/server/models/report_dial.js
index c918e3e..200fb4c 100644
--- a/server/models/report_dial.js
+++ b/server/models/report_dial.js
@@ -2,8 +2,6 @@
  * DIAL Model
  */
 
-var emitter = require('cluster-emitter');
-
 module.exports = function(sequelize, DataTypes) {
 
   var ReportDial = sequelize.define('ReportDial', {
@@ -45,11 +43,6 @@ module.exports = function(sequelize, DataTypes) {
     routeId: DataTypes.INTEGER
   }, {
     tableName: 'report_dial',
-    hooks: {
-      afterUpdate: function(doc) {
-        emitter.to(['master']).emit('ReportDial.afterUpdate', doc);
-      }
-    },
     indexes: [{
       fields: ['uniqueid']
     }]
diff --git a/server/models/report_fax.js b/server/models/report_fax.js
index 0b3c66f..aa8a920 100644
--- a/server/models/report_fax.js
+++ b/server/models/report_fax.js
@@ -1,7 +1,6 @@
 'use strict';
 
 var moment = require('moment');
-var emitter = require('cluster-emitter');
 
 module.exports = function(sequelize, DataTypes) {
   return sequelize.define('ReportFax', {
@@ -41,19 +40,6 @@ module.exports = function(sequelize, DataTypes) {
     connectedAt: DataTypes.DATE,
     from: DataTypes.STRING
   }, {
-    tableName: 'report_fax',
-    hooks: {
-      afterCreate: function(doc, options) {
-        emitter.to(['master']).emit('ReportFax.afterCreate', doc);
-      },
-      afterUpdate: function(doc, options) {
-        emitter.to(['master']).emit('ReportFax.afterUpdate', doc, {
-          changed: doc.changed()
-        });
-      },
-      afterDestroy: function(doc, options) {
-        emitter.to(['master']).emit('ReportFax.afterDestroy', doc);
-      }
-    }
+    tableName: 'report_fax'
   });
 };
diff --git a/server/models/report_fax_session.js b/server/models/report_fax_session.js
index 58b1003..4ab8547 100644
--- a/server/models/report_fax_session.js
+++ b/server/models/report_fax_session.js
@@ -1,7 +1,5 @@
 'use strict';
 
-const emitter = require('cluster-emitter');
-
 module.exports = function(sequelize, DataTypes) {
   return sequelize.define('ReportFaxSession', {
     uniqueid: DataTypes.STRING,
@@ -31,17 +29,6 @@ module.exports = function(sequelize, DataTypes) {
       defaultValue: false
     }
   }, {
-    tableName: 'report_fax_session',
-    hooks: {
-      afterCreate: function(doc) {
-        emitter.to(['master']).emit('ReportFaxSession.afterCreate', doc);
-      },
-      afterUpdate: function(doc) {
-        emitter.to(['master']).emit('ReportFaxSession.afterUpdate', doc);
-      },
-      afterDestroy: function(doc) {
-        emitter.to(['master']).emit('ReportFaxSession.afterDestroy', doc);
-      }
-    }
+    tableName: 'report_fax_session'
   });
 };
diff --git a/server/models/report_mail.js b/server/models/report_mail.js
index 7ae36a7..0063f40 100644
--- a/server/models/report_mail.js
+++ b/server/models/report_mail.js
@@ -1,7 +1,6 @@
 'use strict';
 
 const moment = require('moment');
-const emitter = require('cluster-emitter');
 
 module.exports = function(sequelize, DataTypes) {
   var ReportMail = sequelize.define('ReportMail', {
@@ -42,22 +41,7 @@ module.exports = function(sequelize, DataTypes) {
     connectedAt: DataTypes.DATE,
     from: DataTypes.STRING
   }, {
-    tableName: 'report_mail',
-    hooks: {
-      afterCreate: function(doc, options) {
-        emitter.to(['master']).emit('ReportMail.afterCreate', doc, {
-          body: options.body
-        });
-      },
-      afterUpdate: function(doc, options) {
-        emitter.to(['master']).emit('ReportMail.afterUpdate', doc, {
-          changed: doc.changed()
-        });
-      },
-      afterDestroy: function(doc, options) {
-        emitter.to(['master']).emit('ReportMail.afterDestroy', doc);
-      }
-    }
+    tableName: 'report_mail'
   });
 
   return ReportMail;
diff --git a/server/models/report_mail_session.js b/server/models/report_mail_session.js
index 5834b0b..68f3160 100644
--- a/server/models/report_mail_session.js
+++ b/server/models/report_mail_session.js
@@ -3,7 +3,6 @@
  */
 
 var moment = require('moment');
-const emitter = require('cluster-emitter');
 
 module.exports = function(sequelize, DataTypes) {
   var ReportMailSession = sequelize.define('ReportMailSession', {
@@ -35,18 +34,7 @@ module.exports = function(sequelize, DataTypes) {
       defaultValue: false
     }
   }, {
-    tableName: 'report_mail_session',
-    hooks: {
-      afterCreate: function(doc) {
-        emitter.to(['master']).emit('ReportMailSession.afterCreate', doc);
-      },
-      afterUpdate: function(doc) {
-        emitter.to(['master']).emit('ReportMailSession.afterUpdate', doc);
-      },
-      afterDestroy: function(doc) {
-        emitter.to(['master']).emit('ReportMailSession.afterDestroy', doc);
-      }
-    }
+    tableName: 'report_mail_session'
   });
 
   return ReportMailSession;
diff --git a/server/models/report_member.js b/server/models/report_member.js
index ea6c605..1531bad 100644
--- a/server/models/report_member.js
+++ b/server/models/report_member.js
@@ -1,9 +1,6 @@
-/**
- * DIAL Model
- */
+'use strict';
 
 var moment = require('moment');
-var emitter = require('cluster-emitter');
 
 module.exports = function(sequelize, DataTypes) {
 
@@ -37,17 +34,7 @@ module.exports = function(sequelize, DataTypes) {
     internal: DataTypes.INTEGER(11),
     uniqueid: DataTypes.STRING
   }, {
-    tableName: 'report_member',
-    hooks: {
-      afterCreate: function(doc, options) {
-        emitter.to(['master']).emit('ReportMember.afterCreate', doc, {
-          body: options.body
-        });
-      },
-      afterUpdate: function(doc, options) {
-        emitter.to(['master']).emit('ReportMember.afterUpdate', doc);
-      }
-    }
+    tableName: 'report_member'
   });
 
   return ReportMember;
diff --git a/server/models/report_openchannel_session.js b/server/models/report_openchannel_session.js
index 3c47c54..89ede8f 100644
--- a/server/models/report_openchannel_session.js
+++ b/server/models/report_openchannel_session.js
@@ -3,7 +3,6 @@
  */
 
 var moment = require('moment');
-const emitter = require('cluster-emitter');
 
 module.exports = function(sequelize, DataTypes) {
   var ReportOpenchannelSession = sequelize.define('ReportOpenchannelSession', {
@@ -33,18 +32,7 @@ module.exports = function(sequelize, DataTypes) {
       defaultValue: false
     }
   }, {
-    tableName: 'report_openchannel_session',
-    hooks: {
-      afterCreate: function(doc) {
-        emitter.to(['master']).emit('ReportOpenchannelSession.afterCreate', doc);
-      },
-      afterUpdate: function(doc) {
-        emitter.to(['master']).emit('ReportOpenchannelSession.afterUpdate', doc);
-      },
-      afterDestroy: function(doc) {
-        emitter.to(['master']).emit('ReportOpenchannelSession.afterDestroy', doc);
-      }
-    }
+    tableName: 'report_openchannel_session'
   });
 
   return ReportOpenchannelSession;
diff --git a/server/models/report_sms.js b/server/models/report_sms.js
index c77d4ca..befa1df 100644
--- a/server/models/report_sms.js
+++ b/server/models/report_sms.js
@@ -3,7 +3,6 @@
  */
 
 var moment = require('moment');
-var emitter = require('cluster-emitter');
 
 module.exports = function(sequelize, DataTypes) {
 
@@ -44,14 +43,7 @@ module.exports = function(sequelize, DataTypes) {
     },
     connectedAt: DataTypes.DATE
   }, {
-    tableName: 'report_sms',
-    hooks: {
-      afterUpdate: function(doc, options) {
-        emitter.to(['master']).emit('ReportSms.afterUpdate', doc, {
-          changed: doc.changed()
-        });
-      }
-    }
+    tableName: 'report_sms'
   });
 
   return ReportSms;
diff --git a/server/models/report_sms_session.js b/server/models/report_sms_session.js
index 255366b..a67bad9 100644
--- a/server/models/report_sms_session.js
+++ b/server/models/report_sms_session.js
@@ -3,7 +3,6 @@
  */
 
 var moment = require('moment');
-const emitter = require('cluster-emitter');
 
 module.exports = function(sequelize, DataTypes) {
   var ReportSmsSession = sequelize.define('ReportSmsSession', {
@@ -34,18 +33,7 @@ module.exports = function(sequelize, DataTypes) {
       defaultValue: false
     }
   }, {
-    tableName: 'report_sms_session',
-    hooks: {
-      afterCreate: function(doc) {
-        emitter.to(['master']).emit('ReportSmsSession.afterCreate', doc);
-      },
-      afterUpdate: function(doc) {
-        emitter.to(['master']).emit('ReportSmsSession.afterUpdate', doc);
-      },
-      afterDestroy: function(doc) {
-        emitter.to(['master']).emit('ReportSmsSession.afterDestroy', doc);
-      }
-    }
+    tableName: 'report_sms_session'
   });
 
   return ReportSmsSession;
diff --git a/server/models/sms_account.js b/server/models/sms_account.js
index cefbde7..24c7782 100644
--- a/server/models/sms_account.js
+++ b/server/models/sms_account.js
@@ -1,6 +1,5 @@
 'use strict';
 
-var emitter = require('cluster-emitter');
 
 module.exports = function(sequelize, DataTypes) {
   var SmsAccount = sequelize.define('SmsAccount', {
@@ -75,19 +74,6 @@ module.exports = function(sequelize, DataTypes) {
     }
   }, {
     tableName: 'sms_accounts',
-    hooks: {
-      afterCreate: function(doc) {
-        emitter.to(['master']).emit('SmsAccount.afterCreate', doc);
-      },
-      afterUpdate: function(doc) {
-        emitter.to(['master']).emit('SmsAccount.afterUpdate', doc, {
-          changed: doc.changed()
-        });
-      },
-      afterDestroy: function(doc) {
-        emitter.to(['master']).emit('SmsAccount.afterDestroy', doc);
-      }
-    },
     associate: function(models) {
       SmsAccount.hasMany(models.SmsRoom);
       SmsAccount.hasMany(models.SmsApplication, {
diff --git a/server/models/sms_message.js b/server/models/sms_message.js
index 45081c7..8d8b6c7 100644
--- a/server/models/sms_message.js
+++ b/server/models/sms_message.js
@@ -1,6 +1,5 @@
 'use strict';
 
-var emitter = require('cluster-emitter');
 
 module.exports = function(sequelize, DataTypes) {
   var SmsMessage = sequelize.define('SmsMessage', {
@@ -35,13 +34,6 @@ module.exports = function(sequelize, DataTypes) {
     },
   }, {
     tableName: 'sms_messages',
-    hooks: {
-      afterCreate: function(doc, options) {
-        emitter.to(['master']).emit('SmsMessage.afterCreate', doc, {
-          user: options.user
-        });
-      }
-    },
     associate: function(models) {
       SmsMessage.belongsTo(models.User);
       SmsMessage.belongsTo(models.SmsRoom, {
diff --git a/server/models/sms_room.js b/server/models/sms_room.js
index 245fb19..e3e6783 100644
--- a/server/models/sms_room.js
+++ b/server/models/sms_room.js
@@ -1,5 +1,5 @@
 const moment = require('moment');
-const emitter = require('cluster-emitter');
+
 
 module.exports = function(sequelize, DataTypes) {
   var SmsRoom = sequelize.define('SmsRoom', {
@@ -80,14 +80,6 @@ module.exports = function(sequelize, DataTypes) {
     }
   }, {
     tableName: 'sms_rooms',
-    hooks: {
-      afterUpdate: function(doc, options) {
-        emitter.to(['master']).emit('SmsRoom.afterUpdate', doc, {
-          changed: doc.changed(),
-          user: options.user
-        });
-      }
-    },
     associate: function(models) {
       // BINDING
       SmsRoom.hasMany(models.SmsMessage);
diff --git a/server/models/square_odbc.js b/server/models/square_odbc.js
index c6bf132..a8a9bf8 100644
--- a/server/models/square_odbc.js
+++ b/server/models/square_odbc.js
@@ -1,7 +1,5 @@
 'use strict';
 
-var emitter = require('cluster-emitter');
-
 module.exports = function(sequelize, DataTypes) {
 
   var SquareOdbc = sequelize.define('SquareOdbc', {
@@ -18,18 +16,7 @@ module.exports = function(sequelize, DataTypes) {
     },
     description: DataTypes.STRING
   }, {
-    tableName: 'square_odbc',
-    hooks: {
-      afterCreate: function(doc) {
-        emitter.to(['master']).emit('SquareOdbc.afterCreate', doc);
-      },
-      afterUpdate: function(doc) {
-        emitter.to(['master']).emit('SquareOdbc.afterUpdate', doc);
-      },
-      afterDestroy: function(doc) {
-        emitter.to(['master']).emit('SquareOdbc.afterDestroy', doc);
-      }
-    }
+    tableName: 'square_odbc'
   });
 
   return SquareOdbc;
diff --git a/server/models/square_project.js b/server/models/square_project.js
index 61dfb71..7834e00 100644
--- a/server/models/square_project.js
+++ b/server/models/square_project.js
@@ -1,6 +1,5 @@
 'use strict';
 
-var emitter = require('cluster-emitter');
 
 module.exports = function(sequelize, DataTypes) {
 
@@ -24,18 +23,7 @@ module.exports = function(sequelize, DataTypes) {
       length: 'long'
     }
   }, {
-    tableName: 'square_projects',
-    hooks: {
-      afterCreate: function(doc) {
-        emitter.to(['master']).emit('SquareProject.afterCreate', doc);
-      },
-      afterUpdate: function(doc) {
-        emitter.to(['master']).emit('SquareProject.afterUpdate', doc);
-      },
-      afterDestroy: function(doc) {
-        emitter.to(['master']).emit('SquareProject.afterDestroy', doc);
-      }
-    }
+    tableName: 'square_projects'
   });
 
   return SquareProject;
diff --git a/server/models/square_recording.js b/server/models/square_recording.js
index 929c747..f69736e 100644
--- a/server/models/square_recording.js
+++ b/server/models/square_recording.js
@@ -2,11 +2,6 @@
  * Square recordings Model
  */
 
-var emitter = require('cluster-emitter');
-
-
-var crypto = require('crypto');
-
 module.exports = function(sequelize, DataTypes) {
 
 	var SquareRecording = sequelize.define('SquareRecording', {
@@ -23,18 +18,7 @@ module.exports = function(sequelize, DataTypes) {
 		filename: DataTypes.STRING,
 		savePath: DataTypes.STRING
 	}, {
-		tableName: 'square_recordings',
-		hooks: {
-			afterCreate: function(doc) {
-				emitter.to(['master']).emit('SquareRecording.afterCreate', doc);
-			},
-			afterUpdate: function(doc) {
-				emitter.to(['master']).emit('SquareRecording.afterUpdate', doc);
-			},
-			afterDestroy: function(doc) {
-				emitter.to(['master']).emit('SquareRecording.afterDestroy', doc);
-			}
-		}
+		tableName: 'square_recordings'
 	});
 
 	return SquareRecording;
diff --git a/server/models/template.js b/server/models/template.js
index 6b8f1a1..6ded5d0 100644
--- a/server/models/template.js
+++ b/server/models/template.js
@@ -3,7 +3,6 @@
  */
 
 var crypto = require('crypto');
-var emitter = require('cluster-emitter');
 
 module.exports = function(sequelize, DataTypes) {
 
@@ -13,18 +12,7 @@ module.exports = function(sequelize, DataTypes) {
 		subject: DataTypes.STRING,
 		html: DataTypes.TEXT
 	}, {
-		tableName: 'tools_templates',
-		hooks: {
-			afterCreate: function(doc) {
-				emitter.to(['master']).emit('Template.afterCreate', doc);
-			},
-			afterUpdate: function(doc) {
-				emitter.to(['master']).emit('Template.afterUpdate', doc);
-			},
-			afterDestroy: function(doc) {
-				emitter.to(['master']).emit('Template.afterDestroy', doc);
-			}
-		}
+		tableName: 'tools_templates'
 	});
 
 	return Template;
diff --git a/server/models/tools_action.js b/server/models/tools_action.js
index 9e04d3f..aaeece0 100644
--- a/server/models/tools_action.js
+++ b/server/models/tools_action.js
@@ -2,8 +2,6 @@
  * Tools Actions Model
  */
 
-var emitter = require('cluster-emitter');
-
 module.exports = function(sequelize, DataTypes) {
 
   var ToolsAction = sequelize.define('ToolsAction', {
@@ -26,17 +24,7 @@ module.exports = function(sequelize, DataTypes) {
       type: DataTypes.STRING(4096)
     }
   }, {
-    tableName: 'tools_actions',
-    hooks: {
-      afterBulkCreate: function(doc) {
-        emitter.to(['master']).emit('ToolsAction.afterBulkCreate', doc);
-      },
-      afterBulkDestroy: function(doc) {
-        emitter.to(['master']).emit('ToolsAction.afterBulkDestroy', doc, {
-          TriggerId: doc.where.TriggerId
-        });
-      }
-    }
+    tableName: 'tools_actions'
   });
 
   return ToolsAction;
diff --git a/server/models/tools_automation.js b/server/models/tools_automation.js
index 996496a..6cc4bc1 100644
--- a/server/models/tools_automation.js
+++ b/server/models/tools_automation.js
@@ -2,7 +2,6 @@
  * Automation Model
  */
 
-var emitter = require('cluster-emitter');
 
 module.exports = function(sequelize, DataTypes) {
 
@@ -20,17 +19,6 @@ module.exports = function(sequelize, DataTypes) {
     }
   }, {
     tableName: 'tools_automations',
-    hooks: {
-      afterCreate: function(doc, options) {
-        emitter.to(['master']).emit('Automation.afterCreate', doc);
-      },
-      afterUpdate: function(doc, options) {
-        emitter.to(['master']).emit('Automation.afterUpdate', doc);
-      },
-      afterDestroy: function(doc, options) {
-        emitter.to(['master']).emit('Automation.afterDestroy', doc);
-      }
-    },
     associate: function(models) {
       Automation.hasMany(models.ToolsCondition, {
         as: {
diff --git a/server/models/tools_condition.js b/server/models/tools_condition.js
index 50902ba..695e44d 100644
--- a/server/models/tools_condition.js
+++ b/server/models/tools_condition.js
@@ -2,8 +2,6 @@
  * Tools Conditions Model
  */
 
-var emitter = require('cluster-emitter');
-
 module.exports = function(sequelize, DataTypes) {
 
   var ToolsCondition = sequelize.define('ToolsCondition', {
@@ -11,22 +9,7 @@ module.exports = function(sequelize, DataTypes) {
     operator: DataTypes.STRING,
     value: DataTypes.STRING
   }, {
-    tableName: 'tools_conditions',
-    hooks: {
-      afterBulkCreate: function(doc) {
-        emitter.to(['master']).emit('ToolsCondition.afterBulkCreate', doc);
-      },
-      afterBulkDestroy: function(doc) {
-        var options = {};
-        if (doc.where.hasOwnProperty('TriggerAllId')) {
-          options.TriggerAllId = doc.where.TriggerAllId;
-        }
-        if (doc.where.hasOwnProperty('TriggerAnyId')) {
-          options.TriggerAnyId = doc.where.TriggerAnyId;
-        }
-        emitter.to(['master']).emit('ToolsCondition.afterBulkDestroy', doc, options);
-      }
-    }
+    tableName: 'tools_conditions'
   });
 
   return ToolsCondition;
diff --git a/server/models/tools_interval.js b/server/models/tools_interval.js
index 2defba0..8addfa8 100644
--- a/server/models/tools_interval.js
+++ b/server/models/tools_interval.js
@@ -1,6 +1,6 @@
 'use strict';
 
-const emitter = require('cluster-emitter');
+
 
 module.exports = function(sequelize, DataTypes) {
   var Interval = sequelize.define('Interval', {
@@ -50,20 +50,6 @@ module.exports = function(sequelize, DataTypes) {
           IntervalId: null
         }
       });
-    },
-    hooks: {
-      afterCreate: function(doc, options) {
-        emitter.to(['master']).emit('Interval.afterCreate', doc);
-      },
-      afterUpdate: function(doc, options) {
-        emitter.to(['master']).emit('Interval.afterUpdate', doc);
-      },
-      afterDestroy: function(doc, options) {
-        emitter.to(['master']).emit('Interval.afterDestroy', doc);
-      },
-      beforeDestroy: function(doc, options) {
-        emitter.to(['master']).emit('Interval.beforeDestroy', doc);
-      }
     }
   });
 
diff --git a/server/models/tools_schedule.js b/server/models/tools_schedule.js
index 1f1b075..1cdadf1 100644
--- a/server/models/tools_schedule.js
+++ b/server/models/tools_schedule.js
@@ -1,7 +1,5 @@
 'use strict';
 
-var emitter = require('cluster-emitter');
-
 module.exports = function(sequelize, DataTypes) {
 
   var Schedule = sequelize.define('Schedule', {
@@ -37,17 +35,6 @@ module.exports = function(sequelize, DataTypes) {
     }
   }, {
     tableName: 'tools_schedules',
-    hooks: {
-      afterCreate: function(doc) {
-        emitter.to(['master']).emit('Schedule.afterCreate', doc);
-      },
-      afterUpdate: function(doc) {
-        emitter.to(['master']).emit('Schedule.afterUpdate', doc);
-      },
-      afterDestroy: function(doc) {
-        emitter.to(['master']).emit('Schedule.afterDestroy', doc);
-      }
-    },
     associate: function(models) {
       Schedule.belongsTo(models.MailServerOut);
     }
diff --git a/server/models/tools_sound.js b/server/models/tools_sound.js
index 8762e09..312166d 100644
--- a/server/models/tools_sound.js
+++ b/server/models/tools_sound.js
@@ -1,7 +1,5 @@
 'use strict';
 
-var emitter = require('cluster-emitter');
-
 
 module.exports = function(sequelize, DataTypes) {
 
@@ -32,18 +30,7 @@ module.exports = function(sequelize, DataTypes) {
 		converted_bitRate: DataTypes.BIGINT,
 		converted_sampleRate: DataTypes.INTEGER
 	}, {
-		tableName: 'tools_sounds',
-		hooks: {
-			afterCreate: function(doc) {
-				emitter.to(['master']).emit('Sound.afterCreate', doc);
-			},
-			afterUpdate: function(doc) {
-				emitter.to(['master']).emit('Sound.afterUpdate', doc);
-			},
-			afterDestroy: function(doc) {
-				emitter.to(['master']).emit('Sound.afterDestroy', doc);
-			}
-		}
+		tableName: 'tools_sounds'
 	});
 
 	return Sound;
diff --git a/server/models/tools_trigger.js b/server/models/tools_trigger.js
index 98dd763..58f32a3 100644
--- a/server/models/tools_trigger.js
+++ b/server/models/tools_trigger.js
@@ -2,8 +2,6 @@
  * Trigger Model
  */
 
-var emitter = require('cluster-emitter');
-
 module.exports = function(sequelize, DataTypes) {
 
   var Trigger = sequelize.define('Trigger', {
@@ -16,19 +14,6 @@ module.exports = function(sequelize, DataTypes) {
     }
   }, {
     tableName: 'tools_triggers',
-    hooks: {
-      afterCreate: function(doc, options) {
-        emitter.to(['master']).emit('Trigger.afterCreate', doc, {
-          newTrigger: options.newTrigger
-        });
-      },
-      afterUpdate: function(doc) {
-        emitter.to(['master']).emit('Trigger.afterUpdate', doc);
-      },
-      afterDestroy: function(doc) {
-        emitter.to(['master']).emit('Trigger.afterDestroy', doc);
-      }
-    },
     associate: function(models) {
       Trigger.hasMany(models.ToolsCondition, {
         as: {
diff --git a/server/models/tools_trunk.js b/server/models/tools_trunk.js
index 0987362..f9df7ff 100644
--- a/server/models/tools_trunk.js
+++ b/server/models/tools_trunk.js
@@ -1,6 +1,6 @@
 'use strict';
 
-const emitter = require('cluster-emitter');
+
 
 module.exports = function(sequelize, DataTypes) {
   var Trunk = sequelize.define('Trunk', {
@@ -462,24 +462,7 @@ module.exports = function(sequelize, DataTypes) {
       type: DataTypes.STRING
     }
   }, {
-    tableName: 'tools_trunks',
-    hooks: {
-      afterCreate: function(doc, options) {
-        emitter.to(['master']).emit('Trunk.afterCreate', doc, {
-          body: options.body
-        });
-      },
-      afterUpdate: function(doc, options) {
-        if (doc.changed('name')) {
-          throw new Error("You can't modify a trunk name");
-        }
-
-        emitter.to(['master']).emit('Trunk.afterUpdate', doc);
-      },
-      afterDestroy: function(doc, options) {
-        emitter.to(['master']).emit('Trunk.afterDestroy', doc);
-      }
-    }
+    tableName: 'tools_trunks'
   });
 
   return Trunk;
diff --git a/server/models/tools_variable.js b/server/models/tools_variable.js
index 8196d55..a874a6d 100644
--- a/server/models/tools_variable.js
+++ b/server/models/tools_variable.js
@@ -1,7 +1,5 @@
 'use strict';
 
-var emitter = require('cluster-emitter');
-
 module.exports = function(sequelize, DataTypes) {
 
   var Variable = sequelize.define('Variable', {
@@ -16,17 +14,6 @@ module.exports = function(sequelize, DataTypes) {
     description: DataTypes.STRING
   }, {
     tableName: 'tools_variables',
-    hooks: {
-      afterCreate: function(doc) {
-        emitter.to(['master']).emit('Variable.afterCreate', doc);
-      },
-      afterUpdate: function(doc) {
-        emitter.to(['master']).emit('Variable.afterUpdate', doc);
-      },
-      afterDestroy: function(doc) {
-        emitter.to(['master']).emit('Variable.afterDestroy', doc);
-      }
-    },
     associate: function(models) {
       Variable.hasMany(models.ZendeskField);
       Variable.hasMany(models.DeskField);
diff --git a/server/models/user.js b/server/models/user.js
index a45909a..1d5ee5b 100644
--- a/server/models/user.js
+++ b/server/models/user.js
@@ -5,7 +5,6 @@ var md5 = require('md5');
 var _ = require('lodash');
 var moment = require('moment');
 var VoiceQueue = require('.').VoiceQueue;
-var emitter = require('cluster-emitter');
 
 module.exports = function(sequelize, DataTypes) {
   var User = sequelize.define('User', {
@@ -1066,26 +1065,6 @@ module.exports = function(sequelize, DataTypes) {
         }
         return scope;
       });
-    },
-    hooks: {
-      afterCreate: function(doc, options) {
-        emitter.to(['master']).emit('User.afterCreate', doc, {
-          body: options.body
-        });
-      },
-      afterUpdate: function(doc, options) {
-        emitter.to(['master']).emit('User.afterUpdate', doc, {
-          changed: doc.changed()
-        });
-      },
-      afterDestroy: function(doc, options) {
-        emitter.to(['master']).emit('User.afterDestroy', doc);
-      },
-      beforeUpdate: function(doc, options) {
-        emitter.to(['master']).emit('User.beforeUpdate', doc, {
-          changed: doc.changed()
-        });
-      }
     }
   });
 
diff --git a/server/models/voice_chanspy.js b/server/models/voice_chanspy.js
index 16402d2..48f931f 100644
--- a/server/models/voice_chanspy.js
+++ b/server/models/voice_chanspy.js
@@ -1,7 +1,5 @@
 'use strict';
 
-const emitter = require('cluster-emitter');
-
 module.exports = function(sequelize, DataTypes) {
 
   var ChanSpy = sequelize.define('ChanSpy', {
@@ -29,19 +27,6 @@ module.exports = function(sequelize, DataTypes) {
         onDelete: 'cascade',
         hooks: true
       });
-    },
-    hooks: {
-      afterCreate: function(doc, options) {
-        emitter.to(['master']).emit('ChanSpy.afterCreate', doc, {
-          body: options.body
-        });
-      },
-      afterUpdate: function(doc, options) {
-        emitter.to(['master']).emit('ChanSpy.afterUpdate', doc);
-      },
-      afterDestroy: function(doc, options) {
-        emitter.to(['master']).emit('ChanSpy.afterDestroy', doc);
-      }
     }
   });
 
diff --git a/server/models/voice_context.js b/server/models/voice_context.js
index 9c98115..2386fcc 100644
--- a/server/models/voice_context.js
+++ b/server/models/voice_context.js
@@ -1,6 +1,6 @@
 'use strict';
 
-const emitter = require('cluster-emitter');
+
 
 module.exports = function(sequelize, DataTypes) {
 
@@ -24,25 +24,6 @@ module.exports = function(sequelize, DataTypes) {
         onDelete: 'cascade',
         hooks: true
       });
-    },
-    hooks: {
-      afterCreate: function(doc, options) {
-        emitter.to(['master']).emit('VoiceContext.afterCreate', doc, {
-          body: options.body
-        });
-      },
-      beforeUpdate: function(doc, options) {
-        emitter.to(['master']).emit('VoiceContext.beforeUpdate', doc);
-      },
-      afterUpdate: function(doc, options) {
-        emitter.to(['master']).emit('VoiceContext.afterUpdate', doc);
-      },
-      beforeDestroy: function(doc, options) {
-        emitter.to(['master']).emit('VoiceContext.beforeDestroy', doc);
-      },
-      afterDestroy: function(doc, options) {
-        emitter.to(['master']).emit('VoiceContext.afterDestroy', doc);
-      }
     }
   });
 
diff --git a/server/models/voice_queue.js b/server/models/voice_queue.js
index 4c88b44..b193f1c 100644
--- a/server/models/voice_queue.js
+++ b/server/models/voice_queue.js
@@ -1,7 +1,5 @@
 /* jshint indent: 2 */
 
-var emitter = require('cluster-emitter');
-
 module.exports = function(sequelize, DataTypes) {
   var VoiceQueue = sequelize.define('VoiceQueue', {
     name: {
@@ -288,17 +286,6 @@ module.exports = function(sequelize, DataTypes) {
     }
   }, {
     tableName: 'voice_queues',
-    hooks: {
-      afterCreate: function(doc) {
-        emitter.to(['master']).emit('VoiceQueue.afterCreate', doc);
-      },
-      afterUpdate: function(doc) {
-        emitter.to(['master']).emit('VoiceQueue.afterUpdate', doc);
-      },
-      afterDestroy: function(doc) {
-        emitter.to(['master']).emit('VoiceQueue.afterDestroy', doc);
-      }
-    },
     associate: function(models) {
       VoiceQueue.belongsToMany(models.User, {
         through: models.UserHasVoiceQueue,
diff --git a/server/services/dashboard/hooks/voice.js b/server/services/dashboard/hooks/voice.js
index aa8624d..851df1c 100644
--- a/server/services/dashboard/hooks/voice.js
+++ b/server/services/dashboard/hooks/voice.js
@@ -70,30 +70,30 @@ module.exports = function(n, cpAmi) {
         }
         break;
 
-      default:
-    }
-  });
+      case 'UserHasVoiceQueue.afterBulkCreate':
+        doc.forEach(function(elm) {
+          onSend(n, 'agent:join', elm);
+        });
+        break;
 
-  UserHasVoiceQueue.afterBulkCreate(function(doc) {
-    doc.forEach(function(elm) {
-      onSend(n, 'agent:join', elm);
-    });
-  });
+      case 'UserHasVoiceQueue.afterBulkDestroy':
+        doc.where.queue.forEach(function(elm) {
+          onSend(n, 'agent:leave', {
+            dataValues: {
+              UserId: doc.where.UserId,
+              queue: elm
+            }
+          });
+        });
+        break;
 
-  UserHasVoiceQueue.afterBulkDestroy(function(doc) {
-    doc.where.queue.forEach(function(elm) {
-      onSend(n, 'agent:leave', {
-        dataValues: {
-          UserId: doc.where.UserId,
-          queue: elm
+      case 'UserHasVoiceQueue.afterUpdate':
+        if (doc.changed.lastcall) {
+          onSend(n, 'lastcall', doc);
         }
-      });
-    });
-  });
+        break;
 
-  UserHasVoiceQueue.afterUpdate(function(doc) {
-    if (doc.changed('lastcall')) {
-      onSend(n, 'lastcall', doc);
+      default:
     }
   });
 };