 +
 +http*)
      log "Downloading $SRC"
--    exec_and_log "ssh $DST_HOST wget -O $DST_PATH $SRC"
+-    exec_and_log "$SSH $DST_HOST $WGET -O $DST_PATH $SRC"
 +    exec_and_log "ssh $DST_HOST curl -k -o $DST_PATH $SRC"
      ;;
  
  *)
+     log "Cloning $SRC"
+-    exec_and_log "$SCP $SRC $DST"
++    exec_and_log "scp $SRC $DST"
+     ;;
+ esac
+ 
+-exec_and_log "$SSH $DST_HOST chmod a+rw $DST_PATH"
++exec_and_log "ssh $DST_HOST chmod a+w $DST_PATH"
+ 
+diff --git a/src/tm_mad/tm_common.sh b/src/tm_mad/tm_common.sh
+index 5caba58..4116f45 100644
+--- a/src/tm_mad/tm_common.sh
++++ b/src/tm_mad/tm_common.sh
+@@ -164,3 +164,64 @@ function timeout_exec_and_log
+     fi
+ }
+ 
++function download_extract
++{
++    URL=$1
++    ARCHIVE=$2
++    FILENAME=$3
++    HOST=$4
++
++    if [ "x$HOST" != "x" ]; then
++        SSH_CMD="ssh $HOST"
++    fi
++
++    $SSH_CMD curl -k -o $ARCHIVE $URL
++
++    extract_tar $ARCHIVE $FILENAME $HOST
++
++    $SSH_CMD rm -rf $ARCHIVE
++}
++
++function file_ends_with
++{
++    FILE=$1
++    EXTENSION=$2
++
++    if [ "x$(echo $FILE | grep -E $EXTENSION)" != "x" ]; then
++        echo 0
++    else
++        echo 1
++    fi
++}
++
++function extract_tar
++{
++    ARCHIVE=$1
++    OUTPUT=$2
++    HOST=$3
++
++    if [ $(file_ends_with $ARCHIVE '.tar.gz') = 0 ]; then
++        FORMAT=z
++    elif [ $(file_ends_with $ARCHIVE '.tar.bz2') = 0 ]; then
++        FORMAT=j
++    elif [ $(file_ends_with $ARCHIVE '.tar.xz') = 0 ]; then
++        FORMAT=J
++    fi
++    
++    TAR_CMD="tar -x${FORMAT}f $ARCHIVE"
++
++    if [ "x$HOST" != "x" ]; then
++    SSH_CMD="ssh $HOST"
++    fi
++
++    if [ "x$OUTPUT" != "x" ]; then
++        if [ "x$HOST" != "x" ]; then
++            $SSH_CMD "$TAR_CMD -O > $OUTPUT"
++        else
++            $TAR_CMD -O > $OUTPUT
++        fi
++    else
++        $SSH_CMD $TAR_CMD 
++    fi
++}
++

+
+http*)
     log "Downloading $SRC"
-    exec_and_log "wget -O $DST_PATH $SRC"
+    exec_and_log "curl -k -o $DST_PATH $SRC"
     ;;
 
 *)
diff --git a/src/tm_mad/ssh/tm_clone.sh b/src/tm_mad/ssh/tm_clone.sh
index b853119..1e2829d 100755
--- a/src/tm_mad/ssh/tm_clone.sh
+++ b/src/tm_mad/ssh/tm_clone.sh
@@ -43,9 +43,24 @@ log "Creating directory $DST_DIR"
 exec_and_log "ssh $DST_HOST mkdir -p $DST_DIR"
 
 case $SRC in
-http://*)

diff --git a/src/tm_mad/nfs/tm_clone.sh b/src/tm_mad/nfs/tm_clone.sh
index 2bba596..603128a 100755
--- a/src/tm_mad/nfs/tm_clone.sh
+++ b/src/tm_mad/nfs/tm_clone.sh
@@ -44,9 +44,24 @@ exec_and_log "mkdir -p $DST_DIR"
