diff --git a/session b/session
index e753572..1689f1f 100755
--- a/session
+++ b/session
@@ -6,8 +6,7 @@ CONFIG_FILE="$HOME/.sessionrc"
 typeset -A config
 # Set defaults
 config=(
-    [socket_dir]="/tmp/"
-    [socket_base]="session-$UID"
+    [session_dir]="$HOME/.session/"
     [log_session]="yes"
     [scrollback]="50"
     [detach_char]=""
@@ -25,9 +24,13 @@ if [ -f "$CONFIG_FILE" ]; then
 fi
 
 # Set some variables
-SOCKET_PREFIX="${config[socket_dir]}/${config[socket_base]}-"
-SOCKET_SUFFIX=".socket"
+export ABDUCO_SOCKET_DIR=${config[socket_dir]}
+SOCKET_PREFIX="${config[socket_dir]}/abduco/$USER/"
+SOCKET_SUFFIX="@${HOSTNAME}"
+LOG_PREFIX="${config[socket_dir]}/log/"
 LOG_SUFFIX=".log"
+mkdir -p $SOCKET_PREFIX
+mkdir -p $LOG_PREFIX
 
 # Exit codes
 EXIT_SUCCESS=0
@@ -115,7 +118,12 @@ get_session_path() {
 
 get_log_path() {
   local session_name=$1
-  echo "${SOCKET_PREFIX}${session_name}${LOG_SUFFIX}"
+  echo "${LOG_PREFIX}${session_name}.log"
+}
+
+get_fifo_path() {
+  local session_name=$1
+  echo "${LOG_PREFIX}${session_name}.fifo"
 }
 
 get_session_pid() {
@@ -131,6 +139,16 @@ is_existing_session_path() {
   fi
 }
 
+is_logging() {
+  local session_name=$1
+  local fifo_path=$(get_fifo_path $session_name)
+  if [ -a $fifo_path ]; then
+    true
+  else
+    false
+  fi
+}
+
 is_existing_session_name() {
   is_existing_session_path $(get_session_path $1)
 }
@@ -144,15 +162,15 @@ get_new_session_name() {
 }
 
 exit_if_in_session() {
-  if [ ! -z $DTACH_SOCKET_PATH ]; then
-    echo >&2 "Cannot attach to a session from within a session."
+  if [ ! -z $ABDUCO_SESSION ]; then
+    echo >&2 "Error: currently attached to session $ABDUCO_SESSION."
     exit $EXIT_ALREADY_IN_SESSION
   fi
 }
 
 exit_if_not_in_session() {
-  if [ -z $DTACH_SOCKET_PATH ]; then
-    echo >&2 "Currently not attached to any session."
+  if [ -z $ABDUCO_SESSION ]; then
+    echo >&2 "Error: currently not attached to any session."
     exit $EXIT_NOT_ATTACHED
   fi
 }
@@ -171,6 +189,22 @@ exit_if_nonexisting_session() {
   fi
 }
 
+select_session() {
+  sessions_avail=($(get_available_sessions))
+  if [ ${#sessions_avail[@]} -eq 0 ]; then
+    exit $EXIT_SUCCESS
+  fi
+  echo >&2 "Select a session (q to quit)"
+  select session_name in ${sessions_avail[@]}
+  do
+    if [ -z "$session_name" ]; then
+      exit $EXIT_SUCCESS
+    fi
+    exit_if_nonexisting_session $session_name
+    break
+  done
+}
+
 print_session_info() {
   local session_name=$1
   local session_path=$(get_session_path $session_name)
@@ -193,35 +227,22 @@ shift
 case $mode in
   "")
     exit_if_not_in_session
-    echo "Currently attached to '$DTACH_SESSION_NAME'."
+    echo "Currently attached to '$ABDUCO_SESSION'."
     exit $EXIT_SUCCESS
     ;;
   "attach"|"att"|"a") 
     exit_if_in_session
     # If no session name specified: select interactively
     if [ -z "$1" ]; then
-      sessions_avail=($(get_available_sessions))
-      if [ ${#sessions_avail[@]} -eq 0 ]; then
-        exit $EXIT_SUCCESS
-      fi
-      echo >&2 "Select a session (q to quit)"
-      select session_name in ${sessions_avail[@]}
-      do
-        if [ -z "$session_name" ]; then
-          exit $EXIT_SUCCESS
-        fi
-        exit_if_nonexisting_session $session_name
-        break
-      done
+      select_session
     else
       session_name=$1
       exit_if_nonexisting_session $session_name
     fi
-    session_path=$(get_session_path $session_name)
-    CMD="dtach -a $session_path -e ${config[detach_char]} -r winch "
+    CMD="abduco -a -S -e ${config[detach_char]} $session_name"
     #echo $CMD
     echo "[attached to '$session_name']"
-    [[ "${config[log_session]}" == "yes" ]] && print_scrollback $session_name 
+    is_logging $session_name && print_scrollback $session_name 
     eval $CMD
     exit $EXITSUCCESS
     ;;
@@ -237,20 +258,57 @@ case $mode in
       exit_if_existing_session $session_name
     fi
     session_path=$(get_session_path $session_name)
-    CMD="env DTACH_SOCKET_PATH=$session_path DTACH_SESSION_NAME=$session_name "
-    CMD+="dtach -c $session_path -e ${config[detach_char]} -r winch "
-    if [[ "${config[log_session]}" == "yes" ]]; then
-      log_path=$(get_log_path $session_name)
-      touch $log_path && chmod 600 $log_path
-      CMD+="/bin/script -q -f $log_path" 
-    else
-      CMD+="/bin/bash" 
-    fi
+    CMD="abduco -n $session_name /bin/bash"
     #echo $CMD
     echo "[new session '$session_name']"
     eval $CMD
+#    if [[ "${config[log_session]}" == "yes" ]]; then
+#      log_path=$(get_log_path $session_name)
+#      touch $log_path && chmod 600 $log_path
+#      abduco -r -S -q -l -a $session_name > $log_path &
+#      #disown
+#    fi
+    CMD="abduco -a -S -e ${config[detach_char]} $session_name"
+    eval $CMD
     exit $EXITSUCCESS
     ;;
+  "log")
+    case "$1" in
+      "start"|"stop");;
+      *)
+        echo >&2 "'$(basename $0) log' accepts:"
+        echo >&2 "  start, stop"
+        exit $EXIT_INVALID_SUBMODE
+        ;;
+    esac
+    if [ -z "$2" ]; then
+      exit_if_not_in_session
+      session_name=$ABDUCO_SESSION
+    else
+      session_name=$2
+      exit_if_nonexisting_session $session_name
+    fi
+    log_path=$(get_log_path $session_name)
+    fifo_path=$(get_fifo_path $session_name)
+    case "$1" in
+      "start")
+        if is_logging $session_name; then
+          echo >&2 "Already logging session $session_name."
+          exit $EXIT_ALREADY_LOGGING
+        fi
+        touch $log_path && chmod 600 $log_path
+        mkfifo $fifo_path
+        cat $fifo_path | abduco -r -S -a $session_name &> $log_path && rm $log_path $fifo_path & disown
+        ;;
+      "stop")
+        if ! is_logging $session_name; then
+          echo 2> "Currently not logging session $session_name."
+          exit $EXIT_NOT_LOGGING
+        fi
+        echo > $fifo_path
+        ;;
+    esac
+  ;;
   "terminate"|"term"|"t"|"kill"|"k")
     # Check if we are in terminate/kill mode
     if [[ ${mode::1} == "k" ]]; then
