diff --git a/planetstack/observer/event_manager.py b/planetstack/observer/event_manager.py
index ab50f66..f24026a 100644
--- a/planetstack/observer/event_manager.py
+++ b/planetstack/observer/event_manager.py
@@ -9,127 +9,136 @@
 import base64
 from fofum import Fofum
 
-# decorator that marks dispatachable event methods  
+# decorator that marks dispatachable event methods	
 def event(func):
-    setattr(func, 'event', func.__name__)
-    return func      
+	setattr(func, 'event', func.__name__)
+	return func		 
 
 class EventHandler:
-    # This code is currently not in use.
-    def __init__(self):
-        pass #self.manager = OpenStackManager()
+	# This code is currently not in use.
+	def __init__(self):
+		pass #self.manager = OpenStackManager()
 
-    @staticmethod
-    def get_events():
-        events = []
-        for name in dir(EventHandler):
-            attribute = getattr(EventHandler, name)
-            if hasattr(attribute, 'event'):
-                events.append(getattr(attribute, 'event'))
-        return events
+	@staticmethod
+	def get_events():
+		events = []
+		for name in dir(EventHandler):
+			attribute = getattr(EventHandler, name)
+			if hasattr(attribute, 'event'):
+				events.append(getattr(attribute, 'event'))
+		return events
 
-    def dispatch(self, event, *args, **kwds):
-        if hasattr(self, event):
-            return getattr(self, event)(*args, **kwds)
-            
-        
-    @event
-    def save_site(self, id):
-        sites = Site.objects.filter(id=id)
-        if sites:
-            self.manager.save_site(sites[0])
-    
-    @event
-    def delete_site(self, tenant_id):
-        self.manager.driver.delete_tenant(tenant_id)
+	def dispatch(self, event, *args, **kwds):
+		if hasattr(self, event):
+			return getattr(self, event)(*args, **kwds)
+			
+		
+	@event
+	def save_site(self, id):
+		sites = Site.objects.filter(id=id)
+		if sites:
+			self.manager.save_site(sites[0])
+	
+	@event
+	def delete_site(self, tenant_id):
+		self.manager.driver.delete_tenant(tenant_id)
 
-    @event
-    def save_site_privilege(self, id):
-        site_privileges = SitePrivilege.objects.filter(id=id)
-        if site_privileges:
-            site_priv = self.manager.save_site_privilege(site_privileges[0])
+	@event
+	def save_site_privilege(self, id):
+		site_privileges = SitePrivilege.objects.filter(id=id)
+		if site_privileges:
+			site_priv = self.manager.save_site_privilege(site_privileges[0])
 
-    @event
-    def delete_site_privilege(self, kuser_id, tenant_id, role_type):
-        self.manager.driver.delete_user_role(kuser_id, tenant_id, role_type)
+	@event
+	def delete_site_privilege(self, kuser_id, tenant_id, role_type):
+		self.manager.driver.delete_user_role(kuser_id, tenant_id, role_type)
 
-    @event
-    def save_slice(self, id):
-        slices = Slice.objects.filter(id=id)
-        if slices:
-            self.manager.save_slice(slices[0])
-    
-    @event
-    def delete_slice(self, tenant_id, network_id, router_id, subnet_id):
-        self.manager._delete_slice(tenant_id, network_id, router_id, subnet_id)
+	@event
+	def save_slice(self, id):
+		slices = Slice.objects.filter(id=id)
+		if slices:
+			self.manager.save_slice(slices[0])
+	
+	@event
+	def delete_slice(self, tenant_id, network_id, router_id, subnet_id):
+		self.manager._delete_slice(tenant_id, network_id, router_id, subnet_id)
 
-    @event
-    def save_user(self, id):
-        users = User.objects.filter(id=id)
-        if users:
-            self.manager.save_user(users[0])
-        
-    @event
-    def delete_user(self, kuser_id):
-        self.manager.driver.delete_user(kuser_id)
-    
-    @event
-    def save_sliver(self, id):
-        slivers = Sliver.objects.filter(id=id)
-        if slivers:
-            self.manager.save_sliver(slivers[0])
+	@event
+	def save_user(self, id):
+		users = User.objects.filter(id=id)
+		if users:
+			self.manager.save_user(users[0])
+		
+	@event
+	def delete_user(self, kuser_id):
+		self.manager.driver.delete_user(kuser_id)
+	
+	@event
+	def save_sliver(self, id):
+		slivers = Sliver.objects.filter(id=id)
+		if slivers:
+			self.manager.save_sliver(slivers[0])
 
-    @event
-    def delete_sliver(self, instance_id):
-        self.manager.destroy_instance(instance_id)                            
+	@event
+	def delete_sliver(self, instance_id):
+		self.manager.destroy_instance(instance_id)							  
 
-    
+	
 class EventSender:
-    def __init__(self,user=None,clientid=None):
-        try:
-            clid = Config().feefie_client_id
-            user = Config().feefie_client_user
-        except:
-            clid = 'planetstack_core_team'
-            user = 'pl'
+	def __init__(self,user=None,clientid=None):
+		try:
+			clid = Config().feefie_client_id
+			user = Config().feefie_client_user
+		except:
+			clid = 'planetstack_core_team'
+			user = 'pl'
 
-        self.fofum = Fofum(user=user)
-        self.fofum.make(clid)
+		self.fofum = Fofum(user=user)
+		self.fofum.make(clid)
 
-    def fire(self):
-        self.fofum.fire()
+	def fire(self):
+		self.fofum.fire()
 
 class EventListener:
-    def __init__(self,wake_up=None):
-        self.handler = EventHandler()
-        self.wake_up = wake_up
+	def __init__(self,wake_up=None):
+		self.handler = EventHandler()
+		self.wake_up = wake_up
 
-    def handle_event(self, payload):
-        payload_dict = json.loads(payload)
+	def handle_event(self, payload):
+		payload_dict = json.loads(payload)
 
 	# The code below will come back when we optimize the observer syncs
 	# into 'small' and 'big' syncs.
 
-        #event = payload_dict['event']
-        #ctx = payload_dict['ctx']
-        #self.handler.dispatch(event,**ctx)   
+		#event = payload_dict['event']
+		#ctx = payload_dict['ctx']
+		#self.handler.dispatch(event,**ctx)   
 
-        if (self.wake_up):
-            self.wake_up()
-        
+		try:
+			deletion = payload_dict['deletion_flag']
+			if (deletion):
+				cmd = payload_dict['command']
+				ctx = payload_dict['ctx']
+				self.handler.dispatch(cmd,**ctx)
+		except:
+			deletion = False
 
-    def run(self):
-        # This is our unique client id, to be used when firing and receiving events
-        # It needs to be generated once and placed in the config file
+		if (not deletion and self.wake_up):
+			self.wake_up()
+		
 
-        try:
-            clid = Config().feefie_client_id
-            user = Config().feefie_client_user
-        except:
-            clid = 'planetstack_core_team'
-            user = 'pl'
+	def run(self):
+		# This is our unique client id, to be used when firing and receiving events
+		# It needs to be generated once and placed in the config file
 
-        f = Fofum(user=user)
-        
-        listener_thread = threading.Thread(target=f.listen_for_event,args=(clid,self.handle_event))
-        listener_thread.start()
+		try:
+			clid = Config().feefie_client_id
+			user = Config().feefie_client_user
+		except:
+			clid = 'planetstack_core_team'
+			user = 'pl'
+
+		f = Fofum(user=user)
+		
+		listener_thread = threading.Thread(target=f.listen_for_event,args=(clid,self.handle_event))
+		listener_thread.start()
