Bug fixes

Many bug fixes with directories