diff --git a/docker_build b/docker_build
index aa6b483722ca15623466a134834a33ee1fa6aee9_ZG9ja2VyX2J1aWxk..82efd72a5f4861ba07dd04e67eee31296bd93007_ZG9ja2VyX2J1aWxk 100755
--- a/docker_build
+++ b/docker_build
@@ -13,6 +13,7 @@
 image=$(python -B -c "import ConfigParser ; c = ConfigParser.SafeConfigParser() ; c.read('${project_home}/setup.cfg') ; print (c.has_section('odoo_scripts') and c.has_option('odoo_scripts', 'image') and c.get('odoo_scripts', 'image')) or '$image_default'")
 
 ignore_git=$(python -B -c "import ConfigParser ; c = ConfigParser.SafeConfigParser() ; c.read('${project_home}/setup.cfg') ; print (c.has_section('odoo_scripts') and c.has_option('odoo_scripts', 'ignore_git') and c.get('odoo_scripts', 'ignore_git')) or 'False'")
-docker_module_dir=
+
+pushd $project_home
 
 # Ensureconf 
@@ -17,5 +18,5 @@
 
 # Ensureconf 
-pushd $project_home
-if [ "$ignore_git" = "True" ];
+# TODO handle confnest
+if [[ -d ".hg" ]];
 then
@@ -21,5 +22,3 @@
 then
-    hg cfensureconf || echo "ignore all cfensureconf errors to bypass bad error code with git repositories"
-else
     hg cfensureconf || { echo 'hg cfensureconf failed' ; popd ; exit 1; }
 fi
@@ -24,4 +23,7 @@
     hg cfensureconf || { echo 'hg cfensureconf failed' ; popd ; exit 1; }
 fi
-popd
+
+# TODO only conditionaly do that
+# Conditions could be: detect odoo_modules in Dockerfile.
+$here/docker_build_copy
 
@@ -27,5 +29,8 @@
 
-$here/docker_build_copy
+function clean_on_exit() {
+    $here/docker_build_clean
+}
+trap clean_on_exit INT TERM EXIT
 
 docker build --pull=true --rm=true -t $registry/$image $project_home || { echo 'Build failed' ; exit 1; }
 
@@ -51,5 +56,4 @@
   docker push $registry/$image || { echo 'Push failed' ; exit 1; }
 fi
 
-$here/docker_build_clean
-
+popd
diff --git a/docker_build_clean b/docker_build_clean
index aa6b483722ca15623466a134834a33ee1fa6aee9_ZG9ja2VyX2J1aWxkX2NsZWFu..82efd72a5f4861ba07dd04e67eee31296bd93007_ZG9ja2VyX2J1aWxkX2NsZWFu 100755
--- a/docker_build_clean
+++ b/docker_build_clean
@@ -8,8 +8,8 @@
 # TODO add a way to bypass the value, maybe with a key in the setup.cfg file
 here=$(dirname $0)
 project_home=$(cd $here && cd .. && echo $PWD)
-odoo_modules=$(python -B -c "import ConfigParser ; c = ConfigParser.SafeConfigParser() ; c.read('${project_home}/setup.cfg') ; print (c.has_option('odoo_scripts', 'modules') and c.get('odoo_scripts', 'modules') or '')")
+odoo_modules="$(python -B -c "import ConfigParser ; c = ConfigParser.SafeConfigParser() ; c.read('${project_home}/setup.cfg') ; print (c.has_option('odoo_scripts', 'modules') and ' '.join(c.get('odoo_scripts', 'modules').split()) or '')")"
 
 # Delete odoo modules temp directory
 if [[ -n $odoo_modules ]];
 then
@@ -12,7 +12,7 @@
 
 # Delete odoo modules temp directory
 if [[ -n $odoo_modules ]];
 then
-    echo rm -rf $project_home/odoo_modules
+    rm -rf $project_home/odoo_modules
 fi
 
diff --git a/docker_build_copy b/docker_build_copy
index aa6b483722ca15623466a134834a33ee1fa6aee9_ZG9ja2VyX2J1aWxkX2NvcHk=..82efd72a5f4861ba07dd04e67eee31296bd93007_ZG9ja2VyX2J1aWxkX2NvcHk= 100755
--- a/docker_build_copy
+++ b/docker_build_copy
@@ -10,8 +10,6 @@
 project_home=$(cd $here && cd .. && echo $PWD)
 odoo_modules="$(python -B -c "import ConfigParser ; c = ConfigParser.SafeConfigParser() ; c.read('${project_home}/setup.cfg') ; print (c.has_option('odoo_scripts', 'modules') and ' '.join(c.get('odoo_scripts', 'modules').split()) or '')")"
 
-mkdir -p $project_home/odoo_modules
-
 # Copy modules when specified
 if [[ -n "$odoo_modules" ]];
 then
@@ -15,6 +13,7 @@
 # Copy modules when specified
 if [[ -n "$odoo_modules" ]];
 then
+    mkdir -p $project_home/odoo_modules
     rsync --delete -C --exclude='.hg*' --exclude='.git*' --links --exclude='*.pyc' -r --times $(eval echo $odoo_modules) $project_home/odoo_modules
 fi