diff --git a/matlab/dynare.m b/matlab/dynare.m
index 026670af9fc4c2e6a03f49ae5fc3b3fa4fc7bf10..3ab08aef485d2c5e24db3be395a02e7c024bd848 100644
--- a/matlab/dynare.m
+++ b/matlab/dynare.m
@@ -96,6 +96,10 @@ end
 
 % Testing if file have extension
 % If no extension default .mod is added
+dot_location=(strfind(fname,'.'));
+if length(dot_location)>1
+    error('DYNARE: Periods in filenames are only allowed for .mod or .dyn extensions')
+end
 if isempty(strfind(fname,'.'))
     fnamelength = length(fname);
     fname1 = [fname '.dyn'];
@@ -106,9 +110,10 @@ if isempty(strfind(fname,'.'))
     fname = fname1;
     % Checking file extension
 else
-    if ~strcmp(upper(fname(size(fname,2)-3:size(fname,2))),'.MOD') ...
+    if dot_location~=length(fname)-3 ... %if the file name has fewer than 4 characters and there is a period
+        || ~strcmp(upper(fname(size(fname,2)-3:size(fname,2))),'.MOD') ...
             && ~strcmp(upper(fname(size(fname,2)-3:size(fname,2))),'.DYN')
-        error('DYNARE: argument must be a filename with .mod or .dyn extension')
+        error('DYNARE: argument must be a filename with .mod or .dyn extension and must not include any other periods')
     end;
     fnamelength = length(fname) - 4;
 end;
@@ -155,6 +160,10 @@ if ~exist(fname,'file') || isequal(fname,'dir')
     error(['dynare:: can''t open ' fname])
 end
 
+if ~isvarname(fname(1:end-4))
+    error('DYNARE: argument of dynare must conform to Matlab''s convention for naming functions, i.e. start with a letter and not contain special characters. Please rename your MOD-file.')
+end
+
 % pre-dynare-preprocessor-hook
 if exist(fname(1:end-4),'dir') && exist([fname(1:end-4) filesep 'hooks'],'dir') && exist([fname(1:end-4) filesep 'hooks/priorprocessing.m'],'file')
     run([fname(1:end-4) filesep 'hooks/priorprocessing'])