fixed stats.isDirectory call
fixed global scope handling by AMD modules