Fix tracking of new folders in diagnostic control
Ensure files and folders are sorted in alphabetic order

Fixes #656
Fixes #654