diff --git a/Code/Mantid/Build/Tests/Mantid.properties b/Code/Mantid/Build/Tests/Mantid.properties
index a97ba9a59d29b7669385f7c6bead0ed3e25757a3..88b13d21ddf8bf7e6763c6a083decadb085ccff3 100644
--- a/Code/Mantid/Build/Tests/Mantid.properties
+++ b/Code/Mantid/Build/Tests/Mantid.properties
@@ -23,6 +23,6 @@ pythonscripts.directory = ../../PythonAPI/scripts
 #ManagedWorkspace.LowerMemoryLimit = 0
 ManagedWorkspace.LowerMemoryLimit = 80
 ManagedWorkspace.DataBlockSize = 4000
-ManagedWorkspace.FilePath = /nonsense/fdghjksdg
+ManagedWorkspace.FilePath = .
 
 algorithms.retained = 50
diff --git a/Code/Mantid/Build/Tests/MantidTest.properties b/Code/Mantid/Build/Tests/MantidTest.properties
index caa54de4b0ff0eb1f330ea8a86cfd264967e61b8..c9de08e98b1cd72730714cb07280921f6e996338 100644
--- a/Code/Mantid/Build/Tests/MantidTest.properties
+++ b/Code/Mantid/Build/Tests/MantidTest.properties
@@ -15,4 +15,4 @@ logging.channels.fileChannel.formatter.pattern = %Y-%m-%d %H:%M:%S,%i [%I] %p %s
 
 ManagedWorkspace.LowerMemoryLimit = 1
 ManagedWorkspace.DataBlockSize = 4000
-ManagedWorkspace.FilePath = /tmp
+ManagedWorkspace.FilePath = .
diff --git a/Code/Mantid/Build/Tests/UseManagedWS.properties b/Code/Mantid/Build/Tests/UseManagedWS.properties
index 2317ad25dca0011b3d425ea39d3deb566d025b6f..626c2deb39eaf3bc2c994b60511d83260a58e40f 100644
--- a/Code/Mantid/Build/Tests/UseManagedWS.properties
+++ b/Code/Mantid/Build/Tests/UseManagedWS.properties
@@ -15,4 +15,4 @@ instrumentDefinition.directory = ../../../../Test/Instrument
 # Uncommenting the line below will lead to all 2D workspaces being of the ManagedWorkspace2D variety
 ManagedWorkspace.LowerMemoryLimit = 0
 ManagedWorkspace.DataBlockSize = 1000
-ManagedWorkspace.FilePath = /tmp
+ManagedWorkspace.FilePath = .
diff --git a/Code/Mantid/DataHandling/src/ManagedRawFileWorkspace2D.cpp b/Code/Mantid/DataHandling/src/ManagedRawFileWorkspace2D.cpp
index cf0fab0c9d562d572a2c2b5f328e22b1231ad556..61e0471406b738763bb6f57edf9595f7adb0d98f 100644
--- a/Code/Mantid/DataHandling/src/ManagedRawFileWorkspace2D.cpp
+++ b/Code/Mantid/DataHandling/src/ManagedRawFileWorkspace2D.cpp
@@ -168,22 +168,14 @@ namespace Mantid
     {
         // Look for the (optional) path from the configuration file
         std::string path = Kernel::ConfigService::Instance().getString("ManagedWorkspace.FilePath");
-        if ( !path.empty() )
-        {
-            if ( ( *(path.rbegin()) != '/' ) && ( *(path.rbegin()) != '\\' ) )
-            {
-                path.push_back('/');
-            }
-        }
-	
-	if( !Poco::File(path).exists() )
+	if( path.empty() || !Poco::File(path).exists() || !Poco::File(path).canWrite() )
 	{
 	  path = Mantid::Kernel::ConfigService::Instance().getBaseDir();
+	  g_log.debug() << "Temporary file written to " << path << std::endl;
 	}
-
-	if( !Poco::File(path).canWrite() )
+	if ( ( *(path.rbegin()) != '/' ) && ( *(path.rbegin()) != '\\' ) )
 	{
-	  throw std::runtime_error(std::string("Temporary file path '") + path + "' is not writable");
+	  path.push_back('/');
 	}
 
         std::stringstream filename;
diff --git a/Code/Mantid/DataObjects/src/ManagedWorkspace2D.cpp b/Code/Mantid/DataObjects/src/ManagedWorkspace2D.cpp
index b2eb42dd2e8fc21ce1b839b2805f3e9a57d03fc6..517355456f9e4662f74edc883c0080d97ca758aa 100644
--- a/Code/Mantid/DataObjects/src/ManagedWorkspace2D.cpp
+++ b/Code/Mantid/DataObjects/src/ManagedWorkspace2D.cpp
@@ -87,12 +87,15 @@ void ManagedWorkspace2D::init(const int &NVectors, const int &XLength, const int
 
   // Look for the (optional) path from the configuration file
   std::string path = Kernel::ConfigService::Instance().getString("ManagedWorkspace.FilePath");
-  if ( !path.empty() )
+  if( path.empty() || !Poco::File(path).exists() || !Poco::File(path).canWrite() )
   {
-    if ( ( *(path.rbegin()) != '/' ) && ( *(path.rbegin()) != '\\' ) )
-    {
-      path.push_back('/');
-    }
+    path = Kernel::ConfigService::Instance().getOutputDir();
+    g_log.debug() << "Temporary file written to " << path << std::endl;
+  }
+  // Append a slash if necessary
+  if( ( *(path.rbegin()) != '/' ) && ( *(path.rbegin()) != '\\' ) )
+  {
+    path.push_back('/');
   }
 
   std::stringstream filestem;
diff --git a/Code/Mantid/Kernel/inc/MantidKernel/ConfigService.h b/Code/Mantid/Kernel/inc/MantidKernel/ConfigService.h
index 69c51592889f5d4a3ed54ad939410bce30c28522..54e5e2365ea6fe8640aeb86e33aaeba8572c5fa7 100644
--- a/Code/Mantid/Kernel/inc/MantidKernel/ConfigService.h
+++ b/Code/Mantid/Kernel/inc/MantidKernel/ConfigService.h
@@ -134,7 +134,8 @@ class Logger;
 		std::string getOSVersion();	
 		std::string getCurrentDir();
 		std::string getTempDir();
-    std::string getBaseDir();
+		std::string getBaseDir() const;
+		std::string getOutputDir() const;
 
 	private:
 		friend struct Mantid::Kernel::CreateUsingNew<ConfigServiceImpl>;
diff --git a/Code/Mantid/Kernel/src/ConfigService.cpp b/Code/Mantid/Kernel/src/ConfigService.cpp
index f56de862d51d33281f416cc3374a5ea22c68b948..857ab6db98bcaf28bf72b370a0542459a1ed7c9c 100644
--- a/Code/Mantid/Kernel/src/ConfigService.cpp
+++ b/Code/Mantid/Kernel/src/ConfigService.cpp
@@ -12,6 +12,7 @@
 #include "Poco/Util/PropertyFileConfiguration.h"
 #include "Poco/LoggingFactory.h"
 #include "Poco/Path.h"
+#include "Poco/File.h"
 #include <fstream>
 #include <sstream>
 #include <iostream>
@@ -54,7 +55,7 @@ namespace Mantid
 			//attempt to load the default properties file that resides in the directory of the executable
 			loadConfig( getBaseDir() + m_properties_file_name);
 			//and then append the user properties
-			loadConfig( getBaseDir() + m_user_properties_file_name, true);
+			loadConfig( getOutputDir() + m_user_properties_file_name, true);
 
 			//Fill the list of possible relative path keys that may require conversion to absolute paths
 			m_vConfigPaths.clear();
@@ -122,7 +123,7 @@ namespace Mantid
 		{
 			try
 			{
-				std::fstream filestr ((m_strBaseDir + m_user_properties_file_name).c_str(), std::fstream::out);
+			        std::fstream filestr ((getOutputDir() + m_user_properties_file_name).c_str(), std::fstream::out);
 
 				filestr << "# This file can be used to override any properties for this installation." << std::endl;
 				filestr << "# Any properties found in this file will override any that are found in the Mantid.Properties file" << std::endl;
@@ -138,7 +139,7 @@ namespace Mantid
 			}
 			catch (std::runtime_error ex)
 			{
-				g_log.error()<<"Unable to write out user.properties file to " << m_strBaseDir << m_user_properties_file_name
+				g_log.error()<<"Unable to write out user.properties file to " << getOutputDir() << m_user_properties_file_name
 					<< " error: " << ex.what() << std::endl;
 			}
 
@@ -212,7 +213,7 @@ namespace Mantid
 				// check if we have failed to open the file
 				if ((!good) || (temp==""))
 				{
-					if (filename == m_strBaseDir + m_user_properties_file_name)
+				  if (filename == getOutputDir() + m_user_properties_file_name)
 					{
 						//write out a fresh file
 						createUserPropertiesFile();
@@ -252,6 +253,14 @@ namespace Mantid
 
 			try
 			{
+			        //Ensure that the logging directory exists
+			        Poco::Path logpath(getString("logging.channels.fileChannel.path"));
+				//make this path point to the parent directory and create it if it does not exist
+				logpath.makeParent();
+				if( !logpath.toString().empty() )
+				{
+				  Poco::File(logpath).createDirectory();
+				}
 				//configure the logging framework
 				Poco::Util::LoggingConfigurator configurator;
 				configurator.configure(m_pConf);
@@ -376,11 +385,27 @@ namespace Mantid
 		* running through Python on the command line
 		* @returns The directory to consider as the base directory, including a trailing slash
 		*/
-		std::string ConfigServiceImpl::getBaseDir()
+		std::string ConfigServiceImpl::getBaseDir() const
 		{
 			return m_strBaseDir;
 		}
-
+	        
+	        /**
+		 * Return the directory that Mantid should use for writing files. A trailing slash is appended
+		 * so that filenames can more easily be concatenated with this
+		 */
+	        std::string ConfigServiceImpl::getOutputDir() const
+		{
+             #ifdef _WIN32 
+		  return m_strBaseDir;
+             #else
+		  Poco::Path datadir(m_pSysConfig->getString("system.homeDir"));
+		  datadir.append(".mantid");
+		  // Create the directory if it doesn't already exist
+		  Poco::File(datadir).createDirectory();
+		  return datadir.toString() + "/";
+             #endif
+		}
 
 		/// \cond TEMPLATE 
 
diff --git a/Code/Mantid/PythonAPI/inc/MantidPythonAPI/SimplePythonAPI.h b/Code/Mantid/PythonAPI/inc/MantidPythonAPI/SimplePythonAPI.h
index 7b716691dfb5f8a0932cff37d587fcab0857b12f..e41af5f852e912876279e03587ff99420eee9078 100644
--- a/Code/Mantid/PythonAPI/inc/MantidPythonAPI/SimplePythonAPI.h
+++ b/Code/Mantid/PythonAPI/inc/MantidPythonAPI/SimplePythonAPI.h
@@ -58,7 +58,7 @@ class DLLExport SimplePythonAPI
 
   ///Public methods
   static void createModule(bool gui);
-  static const std::string & getModuleName(); 
+  static std::string getModuleName(); 
   
   private:
   ///private constructor
diff --git a/Code/Mantid/PythonAPI/src/SimplePythonAPI.cpp b/Code/Mantid/PythonAPI/src/SimplePythonAPI.cpp
index 515db8bb27e3a5510d66c886df7e08085f23fa3a..8f9d7929e804e988b41615bddd6984810737f29a 100644
--- a/Code/Mantid/PythonAPI/src/SimplePythonAPI.cpp
+++ b/Code/Mantid/PythonAPI/src/SimplePythonAPI.cpp
@@ -32,9 +32,9 @@ namespace Mantid
      * Return the name of the Python module to be created
      * @returns A string containing the name of the module file
      */
-    const std::string & SimplePythonAPI::getModuleName()
+    std::string SimplePythonAPI::getModuleName()
     {
-      return g_strFilename;
+      return Poco::Path(Mantid::Kernel::ConfigService::Instance().getOutputDir()).append(Poco::Path(g_strFilename)).toString(); 
     }
 
     /**
@@ -46,7 +46,8 @@ namespace Mantid
     void SimplePythonAPI::createModule(bool gui)
     {
       //open file
-      std::ofstream module(getModuleName().c_str());
+      std::string filepath = getModuleName();	
+      std::ofstream module(filepath.c_str());
       // Append the current directory and the scripts directory to the path to make importing
       // other Mantid things easier
       module << 
diff --git a/Code/qtiplot/qtiplot/src/PythonScripting.cpp b/Code/qtiplot/qtiplot/src/PythonScripting.cpp
index 8c61e9820954f55fb82651d8e79dcd0c4e262843..fe81268b86e2143c02fd6753fea351c205abf5b3 100644
--- a/Code/qtiplot/qtiplot/src/PythonScripting.cpp
+++ b/Code/qtiplot/qtiplot/src/PythonScripting.cpp
@@ -287,11 +287,16 @@ bool PythonScripting::loadInitFile(const QString &path)
 	if (pycFile.isReadable() && (pycFile.lastModified() >= pyFile.lastModified())) {
 		// if we have a recent pycFile, use it
 		FILE *f = fopen(pycFile.filePath(), "rb");
-		success = PyRun_SimpleFileEx(f, pycFile.filePath(), false) == 0;
+		success = (PyRun_SimpleFileEx(f, pycFile.filePath(), false) == 0);
 		fclose(f);
-	} else if (pyFile.isReadable() && pyFile.exists()) {
-		// try to compile pyFile to pycFile
-		PyObject *compileModule = PyImport_ImportModule("py_compile");
+	} 
+	else if (pyFile.isReadable() && pyFile.exists()) {
+		// try to compile pyFile to pycFile if the current location is writable
+	  QString testfile(QFileInfo(path).absoluteDir().absoluteFilePath("UNLIKELYFILENAME"));
+	  QFile tester(testfile);
+	  if( tester.open(QIODevice::WriteOnly) )
+	  {
+	        PyObject *compileModule = PyImport_ImportModule("py_compile");
 		if (compileModule) {
 			PyObject *compile = PyDict_GetItemString(PyModule_GetDict(compileModule), "compile");
 			if (compile) {
@@ -309,23 +314,27 @@ bool PythonScripting::loadInitFile(const QString &path)
 		} else
 			PyErr_Print();
 		pycFile.refresh();
-		if (pycFile.isReadable() && (pycFile.lastModified() >= pyFile.lastModified())) {
-			// run the newly compiled pycFile
-			FILE *f = fopen(pycFile.filePath(), "rb");
-			success = PyRun_SimpleFileEx(f, pycFile.filePath(), false) == 0;
-			fclose(f);
-		} else {
-			// fallback: just run pyFile
-			/*FILE *f = fopen(pyFile.filePath(), "r");
-			success = PyRun_SimpleFileEx(f, pyFile.filePath(), false) == 0;
-			fclose(f);*/
-			//TODO: code above crashes on Windows - bug in Python?
-			QFile f(pyFile.filePath());
-			if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
-				QByteArray data = f.readAll();
-				success = PyRun_SimpleString(data.data());
-				f.close();
-			}
+	  }
+	  QFile::remove(testfile);
+	    if (pycFile.isReadable() && (pycFile.lastModified() >= pyFile.lastModified())) {
+		// run the newly compiled pycFile
+		FILE *f = fopen(pycFile.filePath(), "rb");
+		success = (PyRun_SimpleFileEx(f, pycFile.filePath(), false) == 0);
+		fclose(f);
+	      } 
+	      else 
+		{
+		  // fallback: just run pyFile
+		  /*FILE *f = fopen(pyFile.filePath(), "r");
+		    success = PyRun_SimpleFileEx(f, pyFile.filePath(), false) == 0;
+		    fclose(f);*/
+		  //TODO: code above crashes on Windows - bug in Python?
+		  QFile f(pyFile.filePath());
+		  if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
+		    QByteArray data = f.readAll();
+		    success = (PyRun_SimpleString(data.data()) == 0);
+		    f.close();
+		  }
 		}
 	}
 	return success;