Do not read directory twice. This solves #1761 but this may not be the real solution...