diff --git a/autoconf_share/findpkg b/autoconf_share/findpkg
index 85209d87250be87ef9ede6d862d668f8c16c1ee5..b55eb8fcad6702a3fe88eae1f05bb05017eb9e13 100755
--- a/autoconf_share/findpkg
+++ b/autoconf_share/findpkg
@@ -51,20 +51,7 @@ fi
 lfr_srcpkg=`echo $lfr_srcdir | sed -e "s%.*/LOFAR%LOFAR%"`
 # Get the LOFAR base from the full path of this script.
 lfr_sdir=`dirname $0`
-lfr_base=`(cd $lfr_sdir && pwd) | sed -e "s%/LOFAR/.*%/LOFAR%"`
-# Check if no remaining LOFAR part is in rest of path.
-lfr_rest=`(cd $lfr_sdir && pwd) | sed -e "s%^$lfr_base%%"`
-case "$lfr_rest"
-in */LOFAR/*)
-  echo "Your current directory path should not contain LOFAR multiple times"
-  exit 2
-  ;;
-esac
-# Check if root does not have a LOFAR directory.
-if [ -d $lfr_base/LOFAR ]; then
-  echo "Your current LOFAR directory should not have a subdirectory LOFAR"
-  exit 2
-fi
+lfr_base=`(cd $lfr_sdir && pwd) | sed -e "s%\(.*/LOFAR\)/.*%\1%"`
 # Try to determine the build area and the package name.
 # Either the build area is a subdirectory of the package or the
 # package is a subdirectory of the build area.
@@ -86,7 +73,7 @@ if [ "$lfr_error" = "" ]; then
     # Although the build area is a subdirectory of the package,
     # it still does not mean it is in the LOFAR tree.
     # So try to match the path before 'build' with the tree below LOFAR.
-    lfr_pkg=`echo $lfr_curdir | sed -e "s%/build/.*%%"`;
+    lfr_pkg=`echo $lfr_curdir | sed -e "s%\(.*\)/build/.*%\1%"`;
     while [ ! -d ${lfr_base}/${lfr_pkg} ]
     do
       lfr_tdir=`echo $lfr_pkg | sed -e "s%[^/]*/%%"`;
diff --git a/autoconf_share/lofar_init.m4 b/autoconf_share/lofar_init.m4
index 2efa143e4850c9dbad4e6adac39dc1e7da16c45c..c4426d68e790474c2199819232e0487d0db0586a 100644
--- a/autoconf_share/lofar_init.m4
+++ b/autoconf_share/lofar_init.m4
@@ -168,15 +168,9 @@ AC_ARG_ENABLE(lib64,
     lofar_use_root=0;
   fi
   # Find root of user LOFAR directory tree.
-  lfr_top=`(cd $srcdir && pwd) | sed -e "s%/LOFAR/.*%%"`
+  lfr_top=`(cd $srcdir && pwd) | sed -e "s%\(.*\)/LOFAR/.*%\1%"`
   lofar_top_srcdir=$lfr_top/LOFAR;
-  lfr_pkg=`(cd $srcdir && pwd) | sed -e "s%$lofar_top_srcdir%%"`
-  lfr_rest=`(echo $lfr_pkg) | sed -e "s%/LOFAR/.*%/LOFAR%"`
-  if test "$lfr_pkg" != "$lfr_rest"; then
-    ]AC_MSG_ERROR([Directory name LOFAR should be used only once in your path])[
-  fi
-  # Remove leading slash.
-  lfr_package=`echo $lfr_pkg | sed -e "s%^/%%"`
+  lfr_pkg=`(cd $srcdir && pwd) | sed -e "s%$lofar_top_srcdir/%%"`
   lofar_sharedir=$lofar_top_srcdir/autoconf_share
   # Determine if the build area has the compiler name in it
   # and get the root of the build tree.
diff --git a/autoconf_share/lofar_qatools.m4 b/autoconf_share/lofar_qatools.m4
index bad8e469ea49c254f77ed296e9aedaaa6a3a5411..2bdd07d5d41934b8aaffc318fd4ddad803abe39d 100644
--- a/autoconf_share/lofar_qatools.m4
+++ b/autoconf_share/lofar_qatools.m4
@@ -119,7 +119,7 @@ else
 
     # Get absolute top_srcdir for puretool
     lofar_srcdir=`cd $srcdir && pwd`
-    lofar_base=`echo $lofar_srcdir | sed -e "s%/LOFAR/.*%/LOFAR%"`
+    lofar_base=`echo $lofar_srcdir | sed -e "s%\(.*/LOFAR\)/.*%\1%"`
     lofar_puredir=$lofar_base/autoconf_share
 
     CC="$lofar_puredir/puretool $have_purify $have_quantify $have_purecov "'$(top_builddir)'" $puretools_prefix $CC"
@@ -220,7 +220,7 @@ dnl
     # Get absolute top_srcdir for insuretool
     lofar_curwd=`pwd`
     lofar_srcdir=`cd $srcdir && pwd`
-    lofar_base=`echo $lofar_srcdir | sed -e "s%/LOFAR/.*%/LOFAR%"`
+    lofar_base=`echo $lofar_srcdir | sed -e "s%\(.*/LOFAR\)/.*%\1%"`
     lofar_insuredir=$lofar_base/autoconf_share
 
     CC="$lofar_insuredir/insuretool $have_insure $have_inuse $have_tca "'$(top_builddir)'" $insuretools_prefix $CC"
@@ -278,7 +278,7 @@ AC_ARG_WITH(compiletools,
 if test "$with_compiletools" = "yes"; then
     # Get absolute top_srcdir for comiletool
     lofar_srcdir=`cd $srcdir && pwd`
-    lofar_base=`echo $lofar_srcdir | sed -e "s%/LOFAR/.*%/LOFAR%"`
+    lofar_base=`echo $lofar_srcdir | sed -e "s%\(.*/LOFAR\)/.*%\1%"`
     lofar_tooldir=$lofar_base/autoconf_share
 
 #    CC="$lofar_tooldir/compiletool CC $CC"
diff --git a/autoconf_share/lofarconf b/autoconf_share/lofarconf
index 641e5ca0456c5a53a514f1143cc28cfa32cf4d27..c74f7311b30a90a68153b20bb480be08ea732044 100755
--- a/autoconf_share/lofarconf
+++ b/autoconf_share/lofarconf
@@ -36,7 +36,7 @@ lfr_curdir=`pwd`
 # Keep the original source path.
 lfr_sdir=`dirname $0`
 lfr_srcdir=`cd $lfr_sdir && pwd`
-lfr_root=`echo $lfr_srcdir | sed -e "s%/LOFAR/.*%/LOFAR%"`
+lfr_root=`echo $lfr_srcdir | sed -e "s%\(.*/LOFAR\)/.*%\1%"`
 lfr_base=$lfr_root/autoconf_share
 
 lfr_recur=1
diff --git a/autoconf_share/lofarconf_recur b/autoconf_share/lofarconf_recur
index bd11365a7d42370299d80b41135dc53f73dd5002..277a5359efc409a7e00569e30f3408081a05ad33 100755
--- a/autoconf_share/lofarconf_recur
+++ b/autoconf_share/lofarconf_recur
@@ -41,7 +41,7 @@ shift
 lfr_curdir=`pwd`
 # Get the LOFAR base from the full path of this script.
 lfr_sdir=`dirname $0`
-lfr_root=`(cd $lfr_sdir && pwd) | sed -e "s%/LOFAR/.*%/LOFAR%"`
+lfr_root=`(cd $lfr_sdir && pwd) | sed -e "s%\(.*/LOFAR\).*%\1%"`
 lfr_base=$lfr_root/autoconf_share
 
 # Find package, lofar root, compiler, variant.
diff --git a/autoconf_share/runtest.sh b/autoconf_share/runtest.sh
index 20da057718712376d6bcd9ae41017d24821ab7fd..4142c378c2414c455ff2ba8ed4349109141eeed1 100755
--- a/autoconf_share/runtest.sh
+++ b/autoconf_share/runtest.sh
@@ -97,7 +97,7 @@ chmod +w .
 if test -f "$prefix/lofarinit.sh"; then
   lofarinitdir=$prefix
 else
-  lofarinitdir=`pwd | sed -e 's%/LOFAR/.*%/LOFAR/LCS/Tools/src%'`
+  lofarinitdir=`pwd | sed -e 's%\(.*/LOFAR\)/.*%\1/LCS/Tools/src%'`
 fi
 
 if test -r "$lofarinitdir/lofarinit.sh"; then