diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,11 @@
 
+Version 6.1
+-----
+
+* Fixed a space leak in the SignalSource data type.
+
+* Fixed the contAwait function.
+
 Version 6.0
 -----
 
diff --git a/Simulation/Aivika/Internal/Cont.hs b/Simulation/Aivika/Internal/Cont.hs
--- a/Simulation/Aivika/Internal/Cont.hs
+++ b/Simulation/Aivika/Internal/Cont.hs
@@ -722,7 +722,8 @@
                Nothing ->
                  error "The handler was lost: freezeCont."
                Just h ->
-                 do invokeEvent p $ disposeEvent h
+                 do writeIORef rh Nothing
+                    invokeEvent p $ disposeEvent h
                     c <- readIORef rc
                     case c of
                       Nothing -> return ()
@@ -757,7 +758,8 @@
                Nothing ->
                  error "The handler was lost: freezeContReentering."
                Just h ->
-                 do invokeEvent p $ disposeEvent h
+                 do writeIORef rh Nothing
+                    invokeEvent p $ disposeEvent h
                     c <- readIORef rc
                     case c of
                       Nothing -> return ()
@@ -825,7 +827,8 @@
                 Nothing ->
                   error "The handler was lost: sleepCont."
                 Just h ->
-                  do invokeEvent p $ disposeEvent h
+                  do writeIORef rh Nothing
+                     invokeEvent p $ disposeEvent h
                      case e of
                        ContCancellationInitiating ->
                          invokeEvent p $
@@ -877,25 +880,52 @@
 -- | Await the signal.
 contAwait :: Signal a -> Cont a
 contAwait signal =
-  Cont $ \c ->
+  Cont $ \c0 ->
   Event $ \p ->
-  do c <- invokeEvent p $ freezeCont c
-     r <- newIORef Nothing
-     h <- invokeEvent p $
-          handleSignal signal $ 
-          \a -> Event $ 
-                \p -> do x <- readIORef r
-                         case x of
-                           Nothing ->
-                             error "The signal was lost: contAwait."
-                           Just x ->
-                             do invokeEvent p $ disposeEvent x
-                                c <- invokeEvent p $ unfreezeCont c
-                                case c of
-                                  Nothing -> return ()
-                                  Just c  ->
-                                    invokeEvent p $ reenterCont c a
-     writeIORef r $ Just h          
+  do c <- invokeEvent p $ freezeCont c0
+     r1 <- newIORef Nothing
+     r2 <- newIORef Nothing
+     h1 <- invokeEvent p $
+           handleSignal signal $ 
+           \a -> Event $ 
+                 \p -> do x1 <- readIORef r1
+                          x2 <- readIORef r2
+                          writeIORef r1 Nothing
+                          writeIORef r2 Nothing
+                          case x1 of
+                            Nothing ->
+                              return ()
+                            Just h1 ->
+                              invokeEvent p $ disposeEvent h1
+                          case x2 of
+                            Nothing ->
+                              return ()
+                            Just h2 ->
+                              invokeEvent p $ disposeEvent h2
+                          c <- invokeEvent p $ unfreezeCont c
+                          case c of
+                            Nothing -> return ()
+                            Just c  ->
+                              invokeEvent p $ reenterCont c a
+     h2 <- invokeEvent p $
+           handleSignal (contCancellationInitiating $ contId $ contAux c0) $
+           \a -> Event $
+                 \p -> do x1 <- readIORef r1
+                          x2 <- readIORef r2
+                          writeIORef r1 Nothing
+                          writeIORef r2 Nothing
+                          case x1 of
+                            Nothing ->
+                              return ()
+                            Just h1 ->
+                              invokeEvent p $ disposeEvent h1
+                          case x2 of
+                            Nothing ->
+                              return ()
+                            Just h2 ->
+                              invokeEvent p $ disposeEvent h2
+     writeIORef r1 $ Just h1          
+     writeIORef r2 $ Just h2
 
 -- | Like the GoTo statement it transfers the direction of computation,
 -- but raises an exception when used within 'catchCont' or 'finallyCont'.
diff --git a/Simulation/Aivika/Signal.hs b/Simulation/Aivika/Signal.hs
--- a/Simulation/Aivika/Signal.hs
+++ b/Simulation/Aivika/Signal.hs
@@ -165,7 +165,7 @@
 dequeueSignalHandler :: SignalHandlerQueue a -> SignalHandler a -> IO ()
 {-# INLINE dequeueSignalHandler #-}
 dequeueSignalHandler q h = 
-  modifyIORef (queueList q) (delete h)
+  modifyIORef' (queueList q) $ delete h
 
 instance Functor Signal where
   fmap = mapSignal
diff --git a/aivika.cabal b/aivika.cabal
--- a/aivika.cabal
+++ b/aivika.cabal
@@ -1,5 +1,5 @@
 name:            aivika
-version:         6.0.0
+version:         6.1
 synopsis:        A multi-method simulation library
 description:
     Aivika is a discrete event simulation (DES) framework with support of activity-oriented,
