diff --git a/person_detection/base_camera.py b/person_detection/base_camera.py
index 90a2474..0998e1a 100644
--- a/person_detection/base_camera.py
+++ b/person_detection/base_camera.py
@@ -1,90 +1,32 @@
-import time
 import threading
-try:
-    from greenlet import getcurrent as get_ident
-except ImportError:
-    try:
-        from thread import get_ident
-    except ImportError:
-        from _thread import get_ident
-
-
-class CameraEvent(object):
-    """An Event-like class that signals all active clients when a new frame is
-    available.
-    """
-    def __init__(self):
-        self.events = {}
-
-    def wait(self):
-        """Invoked from each client's thread to wait for the next frame."""
-        ident = get_ident()
-        if ident not in self.events:
-            # this is a new client
-            # add an entry for it in the self.events dict
-            # each entry has two elements, a threading.Event() and a timestamp
-            self.events[ident] = [threading.Event(), time.time()]
-        return self.events[ident][0].wait()
-
-    def set(self):
-        """Invoked by the camera thread when a new frame is available."""
-        now = time.time()
-        remove = None
-        for ident, event in self.events.items():
-            if not event[0].isSet():
-                # if this client's event is not set, then set it
-                # also update the last set timestamp to now
-                event[0].set()
-                event[1] = now
-            else:
-                # if the client's event is already set, it means the client
-                # did not process a previous frame
-                # if the event stays set for more than 5 seconds, then assume
-                # the client is gone and remove it
-                if now - event[1] > 5:
-                    remove = ident
-        if remove:
-            del self.events[remove]
-
-    def clear(self):
-        """Invoked from each client's thread after a frame was processed."""
-        self.events[get_ident()][0].clear()
+from queue import Queue
 
 
 class BaseCamera(object):
     thread = {} # background thread that reads frames from camera
-    frame = {} # current frame is stored here by background thread
-    last_access = {}  # time of last client access to the camera
-    event = {}
-    idle = False  # if True, stops thread if no client connected
+    frame = {} # frame queue
 
     def __init__(self, device=None, idle=False):
         """Start the background camera thread if it isn't running yet."""
         self.device = device
-        self.idle = idle
-        BaseCamera.event[self.device] = CameraEvent()
         if self.device not in BaseCamera.thread:
             BaseCamera.thread[self.device] = None
         if BaseCamera.thread[self.device] is None:
-            BaseCamera.last_access[self.device] = time.time()
+
+            self.frame[device] = Queue(100)
 
             # start background frame thread
             BaseCamera.thread[self.device] = threading.Thread(target=self._thread, args=(self.device))
             BaseCamera.thread[self.device].start()
 
             # wait until frames are available
-            while self.get_frame() is None:
-                time.sleep(0)
+            _ = self.get_frame()
 
     def get_frame(self):
         """Return the current camera frame."""
-        BaseCamera.last_access[self.device] = time.time()
 
-        # wait for a signal from the camera thread
-        BaseCamera.event[self.device].wait()
-        BaseCamera.event[self.device].clear()
-
-        return BaseCamera.frame[self.device]
+        # blocks
+        return BaseCamera.frame[self.device].get(block=True)
 
     def frames(self):
         """"Generator that returns frames from the camera."""
@@ -94,16 +36,6 @@
         """Camera background thread."""
         frames_iterator = self.frames()
         for frame in frames_iterator:
-            BaseCamera.frame[device] = frame
-            BaseCamera.event[device].set()  # send signal to clients
-            time.sleep(0)
-
-            if self.idle:
-                # if there hasn't been any clients asking for frames in
-                # the last 10 seconds then stop the thread
-                if time.time() - BaseCamera.last_access[device] > 10:
-                    frames_iterator.close()
-                    print('Stopping camera thread due to inactivity.')
-                    break
+            BaseCamera.frame[device].put(frame, block=True)
 
         BaseCamera.thread[device] = None
diff --git a/person_detection/person_detection.py b/person_detection/person_detection.py
index 8eff1bc..9c5f0d9 100644
--- a/person_detection/person_detection.py
+++ b/person_detection/person_detection.py
@@ -29,7 +29,7 @@
     def __init__(self, device, args):
         log.basicConfig(format="[ %(levelname)s ] %(message)s", level=log.INFO, stream=sys.stdout)
 
-        self.model = args.model
+        self.model_xml = args.model
         self.input = args.input
         self.prob_threshold = args.prob_threshold
 
@@ -61,12 +61,11 @@
 
 
     def init_inference(self):
-        model_xml = self.model
-        model_bin = os.path.splitext(model_xml)[0] + ".bin"
+        self.model_bin = os.path.splitext(self.model_xml)[0] + ".bin"
 
         # Read IR
         log.info("Reading IR...")
-        net = IECore().read_network(model=model_xml, weights=model_bin)
+        net = IECore().read_network(model=self.model_xml, weights=self.model_bin)
 
         assert len(net.inputs.keys()) == 1, "Demo supports only single input topologies"
         assert len(net.outputs) == 1, "Demo supports only single output topologies"
@@ -77,6 +76,7 @@
         exec_net = IECore().load_network(network=net, device_name="CPU", num_requests=2)
         # Read and pre-process input image
         shape = Shape(*net.inputs[input_blob].shape)
+
         del net
 
         return exec_net, shape, input_blob, out_blob
@@ -90,10 +90,6 @@
         cur_request_id = 0
         next_request_id = 1
 
-        log.info("Starting inference in async mode...")
-        log.info("To switch between sync and async modes press Tab button")
-        log.info("To stop the demo execution press Esc button")
-
         # Async doesn't work if True
         # Request issues = Runtime Error: [REQUEST BUSY]
         # self.is_async_mode = False
@@ -146,8 +142,6 @@
                         det_label = str(class_id)
                         cv2.putText(frame, det_label + ' ' + str(round(obj[2] * 100, 1)) + ' %', (xmin, ymin - 7),
                                     cv2.FONT_HERSHEY_COMPLEX, 0.6, color, 1)
-                        # print('Object detected, class_id:', class_id, 'probability:', obj[2], 'xmin:', xmin, 'ymin:', ymin,
-                        #      'xmax:', xmax, 'ymax:', ymax)
 
                 cv2.putText(frame, self.device, (10, int(initial_h - 20)),
                         cv2.FONT_HERSHEY_COMPLEX, 0.5, (10, 10, 200), 1)
