improve script handling
fix missing empty directories