Fixed major bug with directory handling