diff --git a/externals/x13/installx13.m b/externals/x13/installx13.m
index cb299212caccd778506cddc5188a845fda51be96..8c75022f2b61225ab1bdd4f76e462f3124421b69 100644
--- a/externals/x13/installx13.m
+++ b/externals/x13/installx13.m
@@ -25,8 +25,17 @@ if ~exist('x13.zip','file')
         urlwrite('http://www.dynare.org/x13/x13.zip', 'x13.zip');
     end
     unzip('x13.zip');
-    movefile('binaries/linux','./linux');
-    movefile('binaries/osx','./osx');
-    movefile('binaries/windows','./windows');
-    rmdir('binaries');
+    if ismac()
+        mkdir osx
+        movefile('binaries/osx/*','./osx');
+    elseif isunix()
+        mkdir linux
+        movefile('binaries/linux/*','./linux');
+    elseif ispc()
+        mkdir windows
+        movefile('binaries/windows/*','./windows');
+    else
+        error('X13 is not available for the current platform!')
+    end
+    rmdir('binaries', 's');
 end
diff --git a/externals/x13/uninstallx13.m b/externals/x13/uninstallx13.m
index 03c38c42b4a30cc3ba55d705d67b1854be905ab5..2e2c04cfbcd11f87ce65cb493eee77ca12f80f14 100644
--- a/externals/x13/uninstallx13.m
+++ b/externals/x13/uninstallx13.m
@@ -1,6 +1,6 @@
 function uninstallx13()
 
-% Uninstalls CENSUS X13 binaries (Windows and Linux).
+% Uninstalls CENSUS X13 binaries (Windows, OSX and Linux).
 
 % Copyright (C) 2017 Dynare Team
 %
@@ -23,9 +23,13 @@ if exist('x13.zip','file')
 end
 
 if exist('linux','dir')
-    rmdir('linux')
+    rmdir('linux', 's')
 end
 
 if exist('windows','dir')
-    rmdir('windows')
+    rmdir('windows', 's')
 end
+
+if exist('osx','dir')
+    rmdir('osx', 's')
+end
\ No newline at end of file
diff --git a/externals/x13/updatex13.m b/externals/x13/updatex13.m
new file mode 100644
index 0000000000000000000000000000000000000000..d6f8f072fd1df88a2af241de2a3781880a140115
--- /dev/null
+++ b/externals/x13/updatex13.m
@@ -0,0 +1,25 @@
+function updatex13()
+
+% Uninstalls CENSUS X13 binaries (Windows, OSX and Linux).
+
+% Copyright (C) 2017 Dynare Team
+%
+% This code is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% Dynare dseries submodule is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
+
+
+if exist('x13.zip','file')
+    delete('x13.zip')
+end
+
+installx13();
\ No newline at end of file