anchor.diff:                      (cl+ssl::ssl-error-syscall (err)
                         (format t "SSL error ~a~%" err))
                       (orcabot-exiting ()
  +                      (format t "Exiting gracefully~%")
                         (setf *quitting* t)
                         (irc:quit conn "Quitting")
                         (shutdown-dispatcher conn)
  +                      (when (iolib:socket-os-fd (cl-irc::socket conn))
  +                        (iolib:remove-fd-handlers *event-base*
  +                                                  (iolib:socket-os-fd (cl-irc::socket conn))
  +                                                  :read t))
                         (setf conn nil)))
                  (progn
                    (when conn
                      (shutdown-dispatcher conn)
  -                   (close (irc:network-stream conn) :abort t)))))
  -           (unless *quitting*
  -             (format t "Sleeping 10 seconds before reconnecting.~%")
  -             (sleep 10)))
  -      (format t "Exiting gracefully.~%"))))
  +                   (when (iolib:socket-os-fd (cl-irc::socket conn))
  +                     (iolib:remove-fd-handlers *event-base*
  +                                               (iolib:socket-os-fd (cl-irc::socket conn))
  +                                               :read t))
  +                   (close (irc:network-stream conn) :abort t))))))
  +      (unless *quitting*
  +        (format t "Sleeping 10 seconds before reconnecting.~%")
  +        (sleep 10)))))
   
   (defun start-process (function name)
     "Trivial wrapper around implementation thread functions."
  
positive.code:                       (progn
                          (format t "Connecting to server~%")
                          (setf conn (orcabot-connect config))
                          (initialize-access config)
                          (initialize-dispatcher conn config)
                          (handler-bind
                              ((irc:no-such-reply
                                #'(lambda (c)
  
negative.code:      :port port
       :connection-security security)))
  
  (defclass nonblocking-connection (cl-irc::connection)
    ((line-buffer :accessor line-buffer :initform (make-array '(0)
                                                               :adjustable t
                                                               :fill-pointer 0))))
  
  (defmethod cl-irc::irc-message-event (connection (message irc-message))
    "Redefines the standard IRC message-event handler so that it doesn't
  log anything when it receives an unhandled event."
    (declare (ignore connection))
    (cl-irc::apply-to-hooks message))
  
  (defun cl-irc::read-protocol-line (connection)
    "Reads a line from the input network stream, returning a
  character array with the input read."
    (multiple-value-bind (buf buf-len incompletep)
        (cl-irc::read-sequence-until (network-stream connection)
                                     (make-array 1024
                                                 :element-type '(unsigned-byte 8)
                                                 :fill-pointer t)
                                     '(10)
                                     :non-blocking t)
      (let ((line-buffer (line-buffer connection)))
        (loop
           for c across buf
           for i upto (1- buf-len)
           do (vector-push-extend c (line-buffer connection)))
        
        (unless incompletep
          (setf (fill-pointer line-buffer)
                ;; remove all trailing CR and LF characters
                ;; (This allows non-conforming clients to send CRCRLF
                ;;  as a line separator too).
                (or (position-if #'(lambda (x) (member x '(10 13)))
                                 line-buffer :from-end t :end (fill-pointer line-buffer))
                    (fill-pointer line-buffer)))
          (prog1
              (cl-irc::try-decode-line buf cl-irc::*default-incoming-external-formats*)
            ;; Reset line-buffer once the line is decoded
            (setf (fill-pointer line-buffer) 0))))))
  
  (defun main-event-loop (conn)
    (iolib:set-io-handler *event-base*
  