diff --git a/nameserver/MockNameServer.cpp b/nameserver/MockNameServer.cpp
index 69f55191fdfd4fecf0e5fc6180540dbcd7aee703..e8793255403c4a8cd975d46b4ae41a9727cc76fb 100644
--- a/nameserver/MockNameServer.cpp
+++ b/nameserver/MockNameServer.cpp
@@ -156,7 +156,8 @@ void cta::MockNameServer::assertStorageClassIsNotInUse(
 //------------------------------------------------------------------------------
 // constructor
 //------------------------------------------------------------------------------
-cta::MockNameServer::MockNameServer() {  
+cta::MockNameServer::MockNameServer() {
+  umask(0);  
   char path[100];
   strncpy(path, "/tmp/CTATmpFsXXXXXX", 100);
   exception::Errnum::throwOnNull(
@@ -222,7 +223,7 @@ std::string cta::MockNameServer::getDirStorageClass(
 void cta::MockNameServer::createFile(
   const SecurityIdentity &requester,
   const std::string &path,
-  const uint16_t mode) {
+  const mode_t mode) {
   Utils::assertAbsolutePathSyntax(path);  
   const std::string dir = Utils::getEnclosingPath(path);
   assertFsDirExists(m_fsDir + dir);
@@ -313,7 +314,7 @@ cta::UserIdentity cta::MockNameServer::getOwner(
 // createDir
 //------------------------------------------------------------------------------
 void cta::MockNameServer::createDir(const SecurityIdentity &requester,
-  const std::string &path, const uint16_t mode) {  
+  const std::string &path, const mode_t mode) {  
   Utils::assertAbsolutePathSyntax(path);  
   const std::string enclosingPath = Utils::getEnclosingPath(path);
   assertFsDirExists(m_fsDir + enclosingPath);
@@ -322,7 +323,6 @@ void cta::MockNameServer::createDir(const SecurityIdentity &requester,
   const std::string inheritedStorageClass = getDirStorageClass(requester,
     enclosingPath);
   const std::string fsPath = m_fsDir + path;
-  
   if(mkdir(fsPath.c_str(), mode)) {
     const int savedErrno = errno;
     std::ostringstream msg;
diff --git a/nameserver/MockNameServer.hpp b/nameserver/MockNameServer.hpp
index 56b1156ebe6fbaf323694ad9e8fb6a2c063ade72..ab389083fd73450c5f4da8c219e18fa099dbbb99 100644
--- a/nameserver/MockNameServer.hpp
+++ b/nameserver/MockNameServer.hpp
@@ -52,13 +52,13 @@ public:
   
   std::string getDirStorageClass(const SecurityIdentity &requester, const std::string &path) const;
   
-  void createFile(const SecurityIdentity &requester, const std::string &path, const uint16_t mode);
+  void createFile(const SecurityIdentity &requester, const std::string &path, const mode_t mode);
 
   void setOwner(const SecurityIdentity &requester, const std::string &path, const UserIdentity &owner);
 
   UserIdentity getOwner(const SecurityIdentity &requester, const std::string &path) const;
   
-  void createDir(const SecurityIdentity &requester, const std::string &path, const uint16_t mode);
+  void createDir(const SecurityIdentity &requester, const std::string &path, const mode_t mode);
   
   void deleteFile(const SecurityIdentity &requester, const std::string &path);
   
diff --git a/nameserver/NameServer.hpp b/nameserver/NameServer.hpp
index b3e390b5280b1215f1541a6356b0649ebe86ca10..e951e5599fbfeb062e6d3c1a441d489021b97146 100644
--- a/nameserver/NameServer.hpp
+++ b/nameserver/NameServer.hpp
@@ -47,7 +47,7 @@ public:
   virtual void createDir(
     const SecurityIdentity &requester,
     const std::string &path,
-    const uint16_t mode) = 0;
+    const mode_t mode) = 0;
 
   /**
    * Deletes the specified directory.
@@ -153,7 +153,7 @@ public:
   virtual void createFile(
     const SecurityIdentity &requester,
     const std::string &path,
-    const uint16_t mode) = 0;
+    const mode_t mode) = 0;
 
   /**
    * Sets the owner of the specified file or directory entry.
diff --git a/scheduler/DirEntry.cpp b/scheduler/DirEntry.cpp
index 7af6dea1a4f070281129b2c3efcdf96a6fd00f84..30cee60c76e0c2524c292aae9688ceb41c326291 100644
--- a/scheduler/DirEntry.cpp
+++ b/scheduler/DirEntry.cpp
@@ -49,6 +49,7 @@ cta::DirEntry::DirEntry(const EntryType entryType,
   m_name(name),
   m_ownerId(0),
   m_groupId(0),
+  m_mode(0777),
   m_storageClassName(storageClassName) {
 }
 
@@ -84,7 +85,7 @@ uint32_t cta::DirEntry::getGroupId() const throw() {
 //------------------------------------------------------------------------------
 // getMode
 //------------------------------------------------------------------------------
-uint16_t cta::DirEntry::getMode() const throw() {
+mode_t cta::DirEntry::getMode() const throw() {
   return m_mode;
 }
 
diff --git a/scheduler/DirEntry.hpp b/scheduler/DirEntry.hpp
index 9a87a2f54ca312157da977815e4c5bbcffe7d13b..bd13f08b85834cd3c7aa392ffdce56ee54fda2db 100644
--- a/scheduler/DirEntry.hpp
+++ b/scheduler/DirEntry.hpp
@@ -39,7 +39,7 @@ public:
     ENTRYTYPE_DIRECTORY};
 
   /**
-   * Thread safe method that returns the string reprsentation of the specified
+   * Thread safe method that returns the string representation of the specified
    * enumeration value.
    */
   static const char *entryTypeToStr(const EntryType enumValue) throw();
@@ -97,7 +97,7 @@ public:
    *
    * @return The mode bits of the directory entry.
    */
-  uint16_t getMode() const throw();
+  mode_t getMode() const throw();
 
   /**
    * Sets the name of the storage class.
@@ -140,7 +140,7 @@ private:
   /**
    * The mode bits of the directory entry.
    */
-  uint16_t m_mode;
+  mode_t m_mode;
 
   /**
    * The name of the directory's storage class or an empty string if the
diff --git a/scheduler/Scheduler.cpp b/scheduler/Scheduler.cpp
index 8ec80e7d4e4806df4098c80b2853cb39232ae0db..e7992ee478d0cfc58ccedaf7ad13dee1e9c94b32 100644
--- a/scheduler/Scheduler.cpp
+++ b/scheduler/Scheduler.cpp
@@ -38,6 +38,7 @@
 #include "scheduler/TapePool.hpp"
 #include "scheduler/UserIdentity.hpp"
 
+#include <iostream>
 #include <sstream>
 
 //------------------------------------------------------------------------------
@@ -357,7 +358,7 @@ std::list<cta::Tape> cta::Scheduler::getTapes(
 void cta::Scheduler::createDir(
   const SecurityIdentity &requester,
   const std::string &path,
-  const uint16_t mode) {
+  const mode_t mode) {
   m_ns.createDir(requester, path, mode);
 }
 
diff --git a/scheduler/Scheduler.hpp b/scheduler/Scheduler.hpp
index a06b92f7ef90a29a1829aa8ffad7625de274a865..7b23c5133fde5d028632b9c1a2a4e2238c87d871 100644
--- a/scheduler/Scheduler.hpp
+++ b/scheduler/Scheduler.hpp
@@ -432,7 +432,7 @@ public:
   void createDir(
     const SecurityIdentity &requester,
     const std::string &path,
-    const uint16_t mode);
+    const mode_t mode);
   
   /**
    * Sets the owner of the specified file or directory entry.
diff --git a/xroot_plugins/XrdProFile.cpp b/xroot_plugins/XrdProFile.cpp
index 954a29114869df9943fa2c6cb3d5a8bd25031c19..b46690387d00f5b2c7419547907eaa4aa9b34754 100644
--- a/xroot_plugins/XrdProFile.cpp
+++ b/xroot_plugins/XrdProFile.cpp
@@ -115,6 +115,7 @@ void XrdProFile::commandDispatcher(const std::vector<std::string> &tokens, const
   else if("ssc"   == command || "setstorageclass"       == command) {xCom_setstorageclass(tokens, requester);}
   else if("csc"   == command || "clearstorageclass"     == command) {xCom_clearstorageclass(tokens, requester);}
   else if("mkdir" == command)                                       {xCom_mkdir(tokens, requester);}
+  else if("chown" == command)                                       {xCom_chown(tokens, requester);}
   else if("rmdir" == command)                                       {xCom_rmdir(tokens, requester);}
   else if("ls"    == command)                                       {xCom_ls(tokens, requester);}
   else if("a"     == command || "archive"               == command) {xCom_archive(tokens, requester);}
@@ -158,14 +159,17 @@ int XrdProFile::open(const char *fileName, XrdSfsFileOpenMode openMode, mode_t c
     return SFS_OK;
   } catch (cta::exception::Exception &ex) {
     m_data = "[ERROR] CTA exception caught: ";
-    m_data += ex.what();
+    m_data += ex.getMessageValue();
+    m_data += "\n";
     return SFS_OK;
   } catch (std::exception &ex) {
     m_data = "[ERROR] Exception caught: ";
     m_data += ex.what();
+    m_data += "\n";
     return SFS_OK;
   } catch (...) {
     m_data = "[ERROR] Unknown exception caught!";
+    m_data += "\n";
     return SFS_OK;
   }
 }
@@ -623,7 +627,7 @@ void XrdProFile::xCom_tapepool(const std::vector<std::string> &tokens, const cta
                  << " " << it->getCreationLog().user.gid 
                  << " " << it->getCreationLog().host
                  << " " << it->getCreationLog().time
-                 << " " << it->getCreationLog().comment;
+                 << " " << it->getCreationLog().comment << std::endl;
     }
     m_data = responseSS.str();
   }
@@ -755,7 +759,7 @@ void XrdProFile::xCom_logicallibrary(const std::vector<std::string> &tokens, con
                  << " " << it->getCreationLog().user.gid
                  << " " << it->getCreationLog().host
                  << " " << it->getCreationLog().time
-                 << " " << it->getCreationLog().comment;
+                 << " " << it->getCreationLog().comment << std::endl;
     }
     m_data = responseSS.str();
   }
@@ -999,7 +1003,7 @@ void XrdProFile::xCom_listongoingretrievals(const std::vector<std::string> &toke
 void XrdProFile::xCom_listpendingarchivals(const std::vector<std::string> &tokens, const cta::SecurityIdentity &requester) {
   std::stringstream help;
   help << tokens[0] << " lpa/listpendingarchivals --tapepool/-t <tapepool_name>" << std::endl;
-  m_data = "Not implemented yet!";
+  m_data = "Not implemented yet!\n";
 }
   
 //------------------------------------------------------------------------------
@@ -1008,7 +1012,7 @@ void XrdProFile::xCom_listpendingarchivals(const std::vector<std::string> &token
 void XrdProFile::xCom_listpendingretrievals(const std::vector<std::string> &tokens, const cta::SecurityIdentity &requester) {
   std::stringstream help;
   help << tokens[0] << " lpr/listpendingretrievals --vid/-v <vid>" << std::endl;
-  m_data = "Not implemented yet!";
+  m_data = "Not implemented yet!\n";
 }
   
 //------------------------------------------------------------------------------
@@ -1017,7 +1021,7 @@ void XrdProFile::xCom_listpendingretrievals(const std::vector<std::string> &toke
 void XrdProFile::xCom_listdrivestates(const std::vector<std::string> &tokens, const cta::SecurityIdentity &requester) {
   std::stringstream help;
   help << tokens[0] << " lds/listdrivestates" << std::endl;
-  m_data = "Not implemented yet!";
+  m_data = "Not implemented yet!\n";
 }
   
 //------------------------------------------------------------------------------
@@ -1071,7 +1075,27 @@ void XrdProFile::xCom_mkdir(const std::vector<std::string> &tokens, const cta::S
     m_data = help.str();
     return;
   }
-  m_scheduler->createDir(requester, tokens[2], 0777); // we need to set mode appropriately NOT 0777!
+  m_scheduler->createDir(requester, tokens[2], ACCESSPERMS); // we need to set mode appropriately NOT 0777!
+}
+
+//------------------------------------------------------------------------------
+// xCom_chown
+//------------------------------------------------------------------------------
+void XrdProFile::xCom_chown(const std::vector<std::string> &tokens, const cta::SecurityIdentity &requester) {
+  std::stringstream help;
+  help << tokens[0] << " chown <uid> <gid> <dirpath>" << std::endl;
+  if(tokens.size()!=5){
+    m_data = help.str();
+    return;
+  }
+  std::istringstream uid_ss(tokens[2]);
+  int uid = 0;
+  uid_ss >> uid;
+  std::istringstream gid_ss(tokens[3]);
+  int gid = 0;
+  gid_ss >> gid;
+  cta::UserIdentity owner(uid, gid);
+  m_scheduler->setOwner(requester, tokens[4], owner);
 }
   
 //------------------------------------------------------------------------------
@@ -1101,7 +1125,7 @@ void XrdProFile::xCom_ls(const std::vector<std::string> &tokens, const cta::Secu
   std::ostringstream responseSS;
   while(dirIterator.hasMore()) {
     auto dirEntry = dirIterator.next();
-    responseSS << (S_ISDIR(dirEntry.getMode()) ? "d" : "-")
+    responseSS << ((dirEntry.getType()==dirEntry.ENTRYTYPE_DIRECTORY) ? "d" : "-")
                << ((dirEntry.getMode() & S_IRUSR) ? "r" : "-")
                << ((dirEntry.getMode() & S_IWUSR) ? "w" : "-")
                << ((dirEntry.getMode() & S_IXUSR) ? "x" : "-")
@@ -1208,6 +1232,7 @@ std::string XrdProFile::getGenericHelp(const std::string &programName) const {
   help << programName << " ssc/setstorageclass" << std::endl;
   help << programName << " csc/clearstorageclass" << std::endl;
   help << programName << " mkdir" << std::endl;
+  help << programName << " chown" << std::endl;
   help << programName << " rmdir" << std::endl;
   help << programName << " ls" << std::endl;
   help << programName << " a/archive" << std::endl;
diff --git a/xroot_plugins/XrdProFile.hpp b/xroot_plugins/XrdProFile.hpp
index cbaf697439a75bc890d19aa1dfd6408d568b9221..843850aef3693ca8d047b40efba4cfe5bb9d1209 100644
--- a/xroot_plugins/XrdProFile.hpp
+++ b/xroot_plugins/XrdProFile.hpp
@@ -211,6 +211,13 @@ protected:
    */
   void xCom_mkdir(const std::vector<std::string> &tokens, const cta::SecurityIdentity &requester);
   
+  /**
+   * Executes the chown command
+   * 
+   * @param tokens The command line tokens
+   */
+  void xCom_chown(const std::vector<std::string> &tokens, const cta::SecurityIdentity &requester);
+  
   /**
    * Executes the rmdir command
    *