diff --git a/CMakeLists.txt b/CMakeLists.txt
index d07d010..76adbc9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -46,6 +46,7 @@ FIND_PACKAGE(CURL QUIET)
 FIND_PACKAGE(CLucene QUIET)
 FIND_PACKAGE(PkgConfig QUIET)
 FIND_PACKAGE(Regex QUIET)
+FIND_PACKAGE(Glib QUIET REQUIRED)
 
 ###########################################################################################
 # Based on user input and the results of the above tests, we may need to mux with the source
@@ -184,12 +185,14 @@ IF(REGEX_FOUND AND CROSS_COMPILE_MINGW32)
 	SET(SWORD_LINK_LIBRARIES ${SWORD_LINK_LIBRARIES} ${REGEX_LIBRARY})
 ENDIF(REGEX_FOUND AND CROSS_COMPILE_MINGW32)
 
+INCLUDE_DIRECTORIES(${Glib_INCLUDE_DIRS})
+
 IF(BUILDING_SHARED)
-	TARGET_LINK_LIBRARIES(sword ${SWORD_LINK_LIBRARIES})
+	TARGET_LINK_LIBRARIES(sword ${SWORD_LINK_LIBRARIES} ${Glib_LIBRARIES})
 ENDIF(BUILDING_SHARED)
 
 IF(BUILDING_STATIC)
-	TARGET_LINK_LIBRARIES(sword_static ${SWORD_LINK_LIBRARIES})
+	TARGET_LINK_LIBRARIES(sword_static ${SWORD_LINK_LIBRARIES} ${Glib_LIBRARIES})
 ENDIF(BUILDING_STATIC)
 
 MESSAGE(STATUS "Setting link libraries to ${SWORD_LINK_LIBRARIES}")
diff --git a/cmake/FindGlib.cmake b/cmake/FindGlib.cmake
new file mode 100644
index 0000000..d4b73af
--- /dev/null
+++ b/cmake/FindGlib.cmake
@@ -0,0 +1,43 @@
+# - Try to find Glib-2.0 (with gobject)
+# Once done, this will define
+#
+#  Glib_FOUND - system has Glib
+#  Glib_INCLUDE_DIRS - the Glib include directories
+#  Glib_LIBRARIES - link these to use Glib
+
+include(LibFindMacros)
+
+# Use pkg-config to get hints about paths
+libfind_pkg_check_modules(Glib_PKGCONF glib-2.0)
+
+# Main include dir
+find_path(Glib_INCLUDE_DIR
+  NAMES glib.h
+  PATHS ${Glib_PKGCONF_INCLUDE_DIRS}
+  PATH_SUFFIXES glib-2.0
+)
+
+# Glib-related libraries also use a separate config header, which is in lib dir
+find_path(GlibConfig_INCLUDE_DIR
+  NAMES glibconfig.h
+  PATHS ${Glib_PKGCONF_INCLUDE_DIRS} /usr
+  PATH_SUFFIXES lib/glib-2.0/include
+)
+
+# Finally the library itself
+find_library(Glib_LIBRARY
+  NAMES glib-2.0
+  PATHS ${Glib_PKGCONF_LIBRARY_DIRS}
+)
+find_library(Gobject_LIBRARY
+  NAMES gobject-2.0
+  PATHS ${Glib_PKGCONF_LIBRARY_DIRS}
+)
+
+# Set the include dir variables and the libraries and let libfind_process do the rest.
+# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
+set(Glib_PROCESS_INCLUDES Glib_INCLUDE_DIR GlibConfig_INCLUDE_DIR)
+set(Glib_PROCESS_LIBS Glib_LIBRARY Gobject_LIBRARY)
+libfind_process(Glib)
+
+
diff --git a/cmake/LibFindMacros.cmake b/cmake/LibFindMacros.cmake
new file mode 100644
index 0000000..69975c5
--- /dev/null
+++ b/cmake/LibFindMacros.cmake
@@ -0,0 +1,99 @@
+# Works the same as find_package, but forwards the "REQUIRED" and "QUIET" arguments
+# used for the current package. For this to work, the first parameter must be the
+# prefix of the current package, then the prefix of the new package etc, which are
+# passed to find_package.
+macro (libfind_package PREFIX)
+  set (LIBFIND_PACKAGE_ARGS ${ARGN})
+  if (${PREFIX}_FIND_QUIETLY)
+    set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} QUIET)
+  endif (${PREFIX}_FIND_QUIETLY)
+  if (${PREFIX}_FIND_REQUIRED)
+    set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} REQUIRED)
+  endif (${PREFIX}_FIND_REQUIRED)
+  find_package(${LIBFIND_PACKAGE_ARGS})
+endmacro (libfind_package)
+
+# CMake developers made the UsePkgConfig system deprecated in the same release (2.6)
+# where they added pkg_check_modules. Consequently I need to support both in my scripts
+# to avoid those deprecated warnings. Here's a helper that does just that.
+# Works identically to pkg_check_modules, except that no checks are needed prior to use.
+macro (libfind_pkg_check_modules PREFIX PKGNAME)
+  if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
+    include(UsePkgConfig)
+    pkgconfig(${PKGNAME} ${PREFIX}_INCLUDE_DIRS ${PREFIX}_LIBRARY_DIRS ${PREFIX}_LDFLAGS ${PREFIX}_CFLAGS)
+  else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
+    find_package(PkgConfig)
+    if (PKG_CONFIG_FOUND)
+      pkg_check_modules(${PREFIX} ${PKGNAME})
+    endif (PKG_CONFIG_FOUND)
+  endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
+endmacro (libfind_pkg_check_modules)
+
+# Do the final processing once the paths have been detected.
+# If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain
+# all the variables, each of which contain one include directory.
+# Ditto for ${PREFIX}_PROCESS_LIBS and library files.
+# Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES.
+# Also handles errors in case library detection was required, etc.
+macro (libfind_process PREFIX)
+  # Skip processing if already processed during this run
+  if (NOT ${PREFIX}_FOUND)
+    # Start with the assumption that the library was found
+    set (${PREFIX}_FOUND TRUE)
+
+    # Process all includes and set _FOUND to false if any are missing
+    foreach (i ${${PREFIX}_PROCESS_INCLUDES})
+      if (${i})
+        set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIRS} ${${i}})
+        mark_as_advanced(${i})
+      else (${i})
+        set (${PREFIX}_FOUND FALSE)
+      endif (${i})
+    endforeach (i)
+
+    # Process all libraries and set _FOUND to false if any are missing
+    foreach (i ${${PREFIX}_PROCESS_LIBS})
+      if (${i})
+        set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARIES} ${${i}})
+        mark_as_advanced(${i})
+      else (${i})
+        set (${PREFIX}_FOUND FALSE)
+      endif (${i})
+    endforeach (i)
+
+    # Print message and/or exit on fatal error
+    if (${PREFIX}_FOUND)
+      if (NOT ${PREFIX}_FIND_QUIETLY)
+        message (STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}")
+      endif (NOT ${PREFIX}_FIND_QUIETLY)
+    else (${PREFIX}_FOUND)
+      if (${PREFIX}_FIND_REQUIRED)
+        foreach (i ${${PREFIX}_PROCESS_INCLUDES} ${${PREFIX}_PROCESS_LIBS})
+          message("${i}=${${i}}")
+        endforeach (i)
+        message (FATAL_ERROR "Required library ${PREFIX} NOT FOUND.\nInstall the library (dev version) and try again. If the library is already installed, use ccmake to set the missing variables manually.")
+      endif (${PREFIX}_FIND_REQUIRED)
+    endif (${PREFIX}_FOUND)
+  endif (NOT ${PREFIX}_FOUND)
+endmacro (libfind_process)
+
+macro(libfind_library PREFIX basename)
+  set(TMP "")
+  if(MSVC80)
+    set(TMP -vc80)
+  endif(MSVC80)
+  if(MSVC90)
+    set(TMP -vc90)
+  endif(MSVC90)
+  set(${PREFIX}_LIBNAMES ${basename}${TMP})
+  if(${ARGC} GREATER 2)
+    set(${PREFIX}_LIBNAMES ${basename}${TMP}-${ARGV2})
+    string(REGEX REPLACE "\\." "_" TMP ${${PREFIX}_LIBNAMES})
+    set(${PREFIX}_LIBNAMES ${${PREFIX}_LIBNAMES} ${TMP})
+  endif(${ARGC} GREATER 2)
+  find_library(${PREFIX}_LIBRARY
+    NAMES ${${PREFIX}_LIBNAMES}
+    PATHS ${${PREFIX}_PKGCONF_LIBRARY_DIRS}
+  )
+endmacro(libfind_library)
+
diff --git a/src/mgr/curlftpt.cpp b/src/mgr/curlftpt.cpp
index 046291e..e1a4aa1 100644
--- a/src/mgr/curlftpt.cpp
+++ b/src/mgr/curlftpt.cpp
@@ -30,6 +30,9 @@
 
 #include <swlog.h>
 
+#include <glib.h>
+#include <glib/gstdio.h>
+
 SWORD_NAMESPACE_START
 
 
@@ -57,7 +60,7 @@ int my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) {
 	struct FtpFile *out=(struct FtpFile *)stream;
 	if (out && !out->stream && !out->destBuf) {
 		/* open file for writing */
-		out->stream=fopen(out->filename, "wb");
+		out->stream=g_fopen(out->filename, "wb");
 		if (!out->stream)
 			return -1; /* failure, can't open file to write */
 	}
diff --git a/src/mgr/filemgr.cpp b/src/mgr/filemgr.cpp
index 5b45049..493cfd2 100644
--- a/src/mgr/filemgr.cpp
+++ b/src/mgr/filemgr.cpp
@@ -22,6 +22,8 @@
 
 #include <filemgr.h>
 #include <utilstr.h>
+#include <glib.h>
+#include <glib/gstdio.h>
 
 #include <dirent.h>
 #include <fcntl.h>
@@ -37,6 +39,8 @@
 #include <unistd.h>
 #endif
 
+#include <glib.h>
+#include <glib/gstdio.h>
 
 #ifndef O_BINARY
 #define O_BINARY 0
@@ -123,7 +127,7 @@ FileDesc::FileDesc(FileMgr *parent, const char *path, int mode, int perms, bool
 
 FileDesc::~FileDesc() {
 	if (fd > 0)
-		close(fd);
+	  ::close(fd);
 		
 	if (path)
 		delete [] path;
@@ -225,14 +229,14 @@ int FileMgr::sysOpen(FileDesc *file) {
 				file->next = files;
 				files = file;
 			}
-			if ((!access(file->path, 04)) || ((file->mode & O_CREAT) == O_CREAT)) {	// check for at least file exists / read access before we try to open
+			if ((!g_access(file->path, 04)) || ((file->mode & O_CREAT) == O_CREAT)) {	// check for at least file exists / read access before we try to open
 				char tries = (((file->mode & O_RDWR) == O_RDWR) && (file->tryDowngrade)) ? 2 : 1;  // try read/write if possible
 				for (int i = 0; i < tries; i++) {
 					if (i > 0) {
 						file->mode = (file->mode & ~O_RDWR);	// remove write access
 						file->mode = (file->mode | O_RDONLY);// add read access
 					}
-					file->fd = ::open(file->path, file->mode|O_BINARY, file->perms);
+					file->fd = g_open(file->path, file->mode|O_BINARY, file->perms);
 
 					if (file->fd >= 0)
 						break;
@@ -275,7 +279,7 @@ signed char FileMgr::trunc(FileDesc *file) {
 		if (i == 9999)
 			return -2;
 
-		int fd = ::open(buf, O_CREAT|O_RDWR, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
+		int fd = g_open(buf, O_CREAT|O_RDWR, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
 		if (fd < 0)
 			return -3;
 	
@@ -289,7 +293,7 @@ signed char FileMgr::trunc(FileDesc *file) {
 		if (size < 1) {
 			// zero out the file
 			::close(file->fd);
-			file->fd = ::open(file->path, O_TRUNC, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
+			file->fd = g_open(file->path, O_TRUNC, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
 			::close(file->fd);
 			file->fd = -77;	// force file open by filemgr
 			// copy tmp file back (dumb, but must preserve file permissions)
@@ -327,7 +331,7 @@ signed char FileMgr::existsFile(const char *ipath, const char *ifileName)
 		ch = path + strlen(path);
 		sprintf(ch, "/%s", ifileName);
 	}
-	signed char retVal = !access(path, 04);
+	signed char retVal = !g_access(path, 04);
 	delete [] path;
 	return retVal;
 }
@@ -349,7 +353,7 @@ signed char FileMgr::existsDir(const char *ipath, const char *idirName)
 		ch = path + strlen(path);
 		sprintf(ch, "/%s", idirName);
 	}
-	signed char retVal = !access(path, 04);
+	signed char retVal = !g_access(path, 04);
 	delete [] path;
 	return retVal;
 }
@@ -368,17 +372,13 @@ int FileMgr::createParent(const char *pName) {
 	}
 	buf[end] = 0;
 	if (strlen(buf)>0) {
-		if (access(buf, 02)) {  // not exists with write access?
-			if ((retCode = mkdir(buf
-#ifndef WIN32
+		if (g_access(buf, 02)) {  // not exists with write access?
+			if ((retCode = g_mkdir(buf
 					, 0755
-#endif
 					))) {
 				createParent(buf);
-				retCode = mkdir(buf
-#ifndef WIN32
+				retCode = g_mkdir(buf
 					, 0755
-#endif
 					);
 			}
 		}
@@ -390,7 +390,7 @@ int FileMgr::createParent(const char *pName) {
 	
 
 int FileMgr::openFileReadOnly(const char *fName) {
-	int fd = ::open(fName, O_RDONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
+	int fd = g_open(fName, O_RDONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
 	return fd;
 }
 
@@ -398,10 +398,10 @@ int FileMgr::openFileReadOnly(const char *fName) {
 int FileMgr::createPathAndFile(const char *fName) {
 	int fd;
 	
-	fd = ::open(fName, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
+	fd = g_open(fName, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
 	if (fd < 1) {
 		createParent(fName);
-		fd = ::open(fName, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
+		fd = g_open(fName, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
 	}
 	return fd;
 }
@@ -411,7 +411,7 @@ int FileMgr::copyFile(const char *sourceFile, const char *targetFile) {
 	int sfd, dfd, len;
 	char buf[4096];
 
-	if ((sfd = ::open(sourceFile, O_RDONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH)) < 1)
+	if ((sfd = g_open(sourceFile, O_RDONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH)) < 1)
 		return -1;
 	if ((dfd = createPathAndFile(targetFile)) < 1)
 		return -1;
@@ -429,7 +429,7 @@ int FileMgr::copyFile(const char *sourceFile, const char *targetFile) {
 
 
 int FileMgr::removeFile(const char *fName) {
-	return ::remove(fName);
+	return g_remove(fName);
 }
 
 char FileMgr::getLine(FileDesc *fDesc, SWBuf &line) {
@@ -506,14 +506,14 @@ char FileMgr::isDirectory(const char *path) {
 
 
 int FileMgr::copyDir(const char *srcDir, const char *destDir) {
-	DIR *dir;
-	struct dirent *ent;
-	if ((dir = opendir(srcDir))) {
-		rewinddir(dir);
-		while ((ent = readdir(dir))) {
-			if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
-				SWBuf srcPath  = (SWBuf)srcDir  + (SWBuf)"/" + ent->d_name;
-				SWBuf destPath = (SWBuf)destDir + (SWBuf)"/" + ent->d_name;
+	GDir *dir;
+	const gchar *ent;
+	if ((dir = g_dir_open(srcDir, 0, NULL))) {
+	  g_dir_rewind(dir);
+	  while ((ent = g_dir_read_name(dir))) {
+			if ((strcmp(ent, ".")) && (strcmp(ent, ".."))) {
+				SWBuf srcPath  = (SWBuf)srcDir  + (SWBuf)"/" + ent;
+				SWBuf destPath = (SWBuf)destDir + (SWBuf)"/" + ent;
 				if (!isDirectory(srcPath.c_str())) {
 					copyFile(srcPath.c_str(), destPath.c_str());
 				}
@@ -522,20 +522,20 @@ int FileMgr::copyDir(const char *srcDir, const char *destDir) {
 				}
 			}
 		}
-		closedir(dir);
+		g_dir_close(dir);
 	}
 	return 0;
 }
 
 
 int FileMgr::removeDir(const char *targetDir) {
-	DIR *dir = opendir(targetDir);
-	struct dirent *ent;
+  GDir *dir = g_dir_open(targetDir, 0, NULL);
+	const gchar *ent;
 	if (dir) {
-		rewinddir(dir);
-		while ((ent = readdir(dir))) {
-			if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
-				SWBuf targetPath = (SWBuf)targetDir + (SWBuf)"/" + ent->d_name;
+	  g_dir_rewind(dir);
+	  while ((ent = g_dir_read_name(dir))) {
+			if ((strcmp(ent, ".")) && (strcmp(ent, ".."))) {
+				SWBuf targetPath = (SWBuf)targetDir + (SWBuf)"/" + ent;
 				if (!isDirectory(targetPath.c_str())) {
 					FileMgr::removeFile(targetPath.c_str());
 				}
@@ -544,14 +544,8 @@ int FileMgr::removeDir(const char *targetDir) {
 				}
 			}
 		}
-		closedir(dir);
+		g_dir_close(dir);
 		FileMgr::removeFile(targetDir);
-/*
-		int status = FileMgr::removeFile(targetDir);
-          int stuff = errno;
-          char *err = strerror(errno);
-          int x = stuff;
-*/
 	}
 	return 0;
 }
diff --git a/src/mgr/installmgr.cpp b/src/mgr/installmgr.cpp
index c1ddd1b..d6ebe5e 100644
--- a/src/mgr/installmgr.cpp
+++ b/src/mgr/installmgr.cpp
@@ -33,6 +33,8 @@ extern "C" {
 #include <utilstr.h>
 
 #include <fcntl.h>
+#include <glib.h>
+#include <glib/gstdio.h>
 
 #include <swmgr.h>
 #include <swmodule.h>
@@ -251,20 +253,19 @@ int InstallMgr::removeModule(SWMgr *manager, const char *moduleName) {
 		}
 		else {	//remove all files in DataPath directory
 
-			DIR *dir;
-			struct dirent *ent;
+			GDir *dir;
+			const gchar *ent;
 			ConfigEntMap::iterator entry;
 
 			FileMgr::removeDir(modDir.c_str());
 
-			if ((dir = opendir(manager->configPath))) {	// find and remove .conf file
-				rewinddir(dir);
-				while ((ent = readdir(dir))) {
-					if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
+			if ((dir = g_dir_open(manager->configPath, 0, NULL))) {	// find and remove .conf file
+			        g_dir_rewind(dir);
+				while ((ent =  g_dir_read_name(dir))) {
 						modFile = manager->configPath;
 						removeTrailingSlash(modFile);
 						modFile += "/";
-						modFile += ent->d_name;
+				  modFile += ent;
 						SWConfig *config = new SWConfig(modFile.c_str());
 						if (config->Sections.find(modName) != config->Sections.end()) {
 							delete config;
@@ -272,8 +273,8 @@ int InstallMgr::removeModule(SWMgr *manager, const char *moduleName) {
 						}
 						else	delete config;
 					}
-				}
-				closedir(dir);
+				g_dir_close(dir);
+				g_free(dir);
 			}
 		}
 		return 0;
@@ -372,8 +373,8 @@ int InstallMgr::installModule(SWMgr *destMgr, const char *fromLocation, const ch
 	SWBuf buffer;
 	bool aborted = false;
 	bool cipher = false;
-	DIR *dir;
-	struct dirent *ent;
+	GDir *dir;
+	const gchar *ent;
 	SWBuf modFile;
 
 	SWLog::getSystemLog()->logDebug("***** InstallMgr::installModule\n");
@@ -485,18 +486,18 @@ int InstallMgr::installModule(SWMgr *destMgr, const char *fromLocation, const ch
 		}
 		if (!aborted) {
 			SWBuf confDir = sourceDir + "mods.d/";
-			if ((dir = opendir(confDir.c_str()))) {	// find and copy .conf file
-				rewinddir(dir);
-				while ((ent = readdir(dir))) {
-					if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
+			if ((dir = g_dir_open(confDir.c_str(), 0, NULL))) {	// find and copy .conf file
+				g_dir_rewind(dir);
+				while ((ent = g_dir_read_name(dir))) {
+					if ((strcmp(ent, ".")) && (strcmp(ent, ".."))) {
 						modFile = confDir;
-						modFile += ent->d_name;
+						modFile += ent;
 						SWConfig *config = new SWConfig(modFile.c_str());
 						if (config->Sections.find(modName) != config->Sections.end()) {
 							SWBuf targetFile = destMgr->configPath; //"./mods.d/";
 							removeTrailingSlash(targetFile);
 							targetFile += "/";
-							targetFile += ent->d_name;
+							targetFile += ent;
 							FileMgr::copyFile(modFile.c_str(), targetFile.c_str());
 							if (cipher) {
 								if (getCipherCode(modName, config)) {
@@ -513,7 +514,7 @@ int InstallMgr::installModule(SWMgr *destMgr, const char *fromLocation, const ch
 						delete config;
 					}
 				}
-				closedir(dir);
+				g_dir_close(dir);
 			}
 		}
 		return (aborted) ? -1 : 0;
diff --git a/src/mgr/swmgr.cpp b/src/mgr/swmgr.cpp
index 27c24f3..08097d6 100644
--- a/src/mgr/swmgr.cpp
+++ b/src/mgr/swmgr.cpp
@@ -23,6 +23,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <fcntl.h>
+#include <glib.h>
+#include <glib/gstdio.h>
 
 #include <sys/stat.h>
 #ifndef _MSC_VER
@@ -270,10 +272,10 @@ void SWMgr::init() {
 SWBuf SWMgr::getHomeDir() {
 
 	// figure out 'home' directory for app data
-	SWBuf homeDir = getenv("HOME");
+	SWBuf homeDir = g_getenv("HOME");
 	if (!homeDir.length()) {
 		// silly windows
-		homeDir = getenv("APPDATA");
+		homeDir = g_getenv("APPDATA");
 	}
 	if (homeDir.length()) {
 		if ((homeDir[homeDir.length()-1] != '\\') && (homeDir[homeDir.length()-1] != '/')) {
@@ -456,7 +458,7 @@ void SWMgr::findConfig(char *configType, char **prefixPath, char **configPath, s
 			// check environment variable SWORD_PATH
 			SWLog::getSystemLog()->logDebug("Checking $SWORD_PATH...");
 
-			SWBuf envsworddir = getenv("SWORD_PATH");
+			SWBuf envsworddir = g_getenv("SWORD_PATH");
 			if (envsworddir.length()) {
 				
 				SWLog::getSystemLog()->logDebug("found (%s).", envsworddir.c_str());
@@ -587,14 +589,15 @@ void SWMgr::findConfig(char *configType, char **prefixPath, char **configPath, s
 
 	SWLog::getSystemLog()->logDebug("Checking $ALLUSERSPROFILE/Application Data/sword/...");
 
-	SWBuf envallusersdir  = getenv("ALLUSERSPROFILE");
+	//SWBuf envallusersdir  = g_getenv("ALLUSERSPROFILE");
+	SWBuf envallusersdir = g_get_system_data_dirs()[0];
 	if (envallusersdir.length()) {
 		SWLog::getSystemLog()->logDebug("found (%s).", envallusersdir.c_str());
 		path = envallusersdir;
 		if ((!path.endsWith("\\")) && (!path.endsWith("/")))
 			path += "/";
 
-		path += "Application Data/sword/";
+		//path += "Application Data/sword/";
 		SWLog::getSystemLog()->logDebug("Checking %s for mods.d...", path.c_str());
 		if (FileMgr::existsDir(path.c_str(), "mods.d")) {
 			SWLog::getSystemLog()->logDebug("found.");
@@ -636,7 +639,7 @@ void SWMgr::findConfig(char *configType, char **prefixPath, char **configPath, s
 
 	if (homeDir.length()) {
 		path = homeDir;
-		path += ".sword/";
+		path += "sword/";
 		SWLog::getSystemLog()->logDebug("  Checking for %smods.conf...", path.c_str());
 		if (FileMgr::existsFile(path.c_str(), "mods.conf")) {
 			SWLog::getSystemLog()->logDebug("found.");
@@ -673,29 +676,29 @@ void SWMgr::findConfig(char *configType, char **prefixPath, char **configPath, s
 
 void SWMgr::loadConfigDir(const char *ipath)
 {
-	DIR *dir;
-	struct dirent *ent;
+	GDir *dir;
+	const gchar *ent;
 	SWBuf newmodfile;
  
-	if ((dir = opendir(ipath))) {
-		rewinddir(dir);
-		while ((ent = readdir(dir))) {
+	if ((dir = g_dir_open(ipath, 0, NULL))) {
+	  g_dir_rewind(dir);
+		while ((ent = g_dir_read_name(dir))) {
 			//check whether it ends with .conf, if it doesn't skip it!
-			if (!ent->d_name || (strlen(ent->d_name) <= 5) || strncmp(".conf", (ent->d_name + strlen(ent->d_name) - 5), 5 )) {
+			if (ent && (strlen(ent) > 5) && strncmp(".conf", (ent + strlen(ent) - 5), 5 )) {
 				continue;
 			}
 			
 			newmodfile = ipath;
 			if ((ipath[strlen(ipath)-1] != '\\') && (ipath[strlen(ipath)-1] != '/'))
 				newmodfile += "/";
-			newmodfile += ent->d_name;
+			newmodfile += ent;
 			if (config) {
 				SWConfig tmpConfig(newmodfile.c_str());
 				*config += tmpConfig;
 			}
 			else	config = myconfig = new SWConfig(newmodfile.c_str());
 		}
-		closedir(dir);
+		g_dir_close(dir);
 		
 		if (!config) {	// if no .conf file exist yet, create a default
 			newmodfile = ipath;
@@ -815,7 +818,7 @@ signed char SWMgr::Load() {
 			SWBuf homeDir = getHomeDir();
 			if (homeDir.length() && configType != 2) { // 2 = user only
 				SWBuf path = homeDir;
-				path += ".sword/";
+				path += "sword/";
 				augmentModules(path.c_str(), mgrModeMultiMod);
 				path = homeDir;
 				path += "sword/";
@@ -1266,21 +1269,21 @@ void SWMgr::deleteModule(const char *modName) {
 
 void SWMgr::InstallScan(const char *dirname)
 {
-   DIR *dir;
-   struct dirent *ent;
+   GDir *dir;
+   const gchar *ent;
    FileDesc *conffd = 0;
    SWBuf newmodfile;
    SWBuf targetName;
  
 	if (FileMgr::existsDir(dirname)) {
-		if ((dir = opendir(dirname))) {
-			rewinddir(dir);
-			while ((ent = readdir(dir))) {
-				if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
+	  if ((dir = g_dir_open(dirname, 0, NULL))) {
+	    g_dir_rewind(dir);
+			while ((ent = g_dir_read_name(dir))) {
+				if ((strcmp(ent, ".")) && (strcmp(ent, ".."))) {
 					newmodfile = dirname;
 					if ((dirname[strlen(dirname)-1] != '\\') && (dirname[strlen(dirname)-1] != '/'))
 						newmodfile += "/";
-					newmodfile += ent->d_name;
+					newmodfile += ent;
 
 					// mods.d
 					if (configType) {
@@ -1289,7 +1292,7 @@ void SWMgr::InstallScan(const char *dirname)
 						targetName = configPath;
 						if ((configPath[strlen(configPath)-1] != '\\') && (configPath[strlen(configPath)-1] != '/'))
 							targetName += "/";
-						targetName += ent->d_name;
+						targetName += ent;
 						conffd = FileMgr::getSystemFileMgr()->open(targetName.c_str(), FileMgr::WRONLY|FileMgr::CREAT, FileMgr::IREAD|FileMgr::IWRITE);
 					}
 
@@ -1311,7 +1314,7 @@ void SWMgr::InstallScan(const char *dirname)
 			}
 			if (conffd)
 				FileMgr::getSystemFileMgr()->close(conffd);
-			closedir(dir);
+			g_dir_close(dir);
 		}
 	}
 }
diff --git a/src/utilfuns/zlib/untgz.c b/src/utilfuns/zlib/untgz.c
index f3f3f56..959a7e4 100644
--- a/src/utilfuns/zlib/untgz.c
+++ b/src/utilfuns/zlib/untgz.c
@@ -5,6 +5,9 @@
  * adaptation to Unix by Jean-loup Gailly <jloup@gzip.org>
  */
 
+#include <glib.h>
+#include <glib/gstdio.h>
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -210,7 +213,7 @@ int makedir (char *newdir)
   if (buffer[len-1] == '/') {
     buffer[len-1] = '\0';
   }
-  if (mkdir(buffer, 0775) == 0)
+  if (g_mkdir(buffer, 0775) == 0)
     {
       free(buffer);
       return 1;
@@ -225,7 +228,7 @@ int makedir (char *newdir)
 	p++;
       hold = *p;
       *p = 0;
-      if ((mkdir(buffer, 0775) == -1) && (errno == ENOENT))
+      if ((g_mkdir(buffer, 0775) == -1) && (errno == ENOENT))
 	{
 	  fprintf(stderr,"%s: couldn't create directory %s\n",prog,buffer);
 	  free(buffer);
@@ -300,15 +303,15 @@ int untar (gzFile in, const char *dest) {
 			case AREGTYPE:
 				remaining = getoct(buffer.header.size,12);
 				if (remaining) {
-					outfile = fopen(fname,"wb");
+					outfile = g_fopen(fname,"wb");
 					if (outfile == NULL) {
 						// try creating directory
 						char *p = strrchr(fname, '/');
 						if (p != NULL) {
 							*p = '\0';
-							makedir(fname);
+							g_mkdir(fname, 0);
 							*p = '/';
-							outfile = fopen(fname,"wb");
+							outfile = g_fopen(fname,"wb");
 						}
 					}
 /*
@@ -353,7 +356,11 @@ int untar (gzFile in, const char *dest) {
 
 					localt = *localtime(&tartime);
 
-					hFile = CreateFile(fname, GENERIC_READ | GENERIC_WRITE,
+					hFile = CreateFileW(g_utf8_to_utf16(fname,
+									    -1,
+									    NULL,
+									    NULL,
+									    NULL), GENERIC_READ | GENERIC_WRITE,
 					0, NULL, OPEN_EXISTING, 0, NULL);
 		  
 					st.wYear = (WORD)localt.tm_year+1900;
