Fixes #1530. Fixes NPE by using IO.listFiles

Fixes #1530.