Fixed issues with directory reading