Fixed bug, added comments

Fixed a bug where the scanner would not pick up subdirectories if there
were no files, added comments to clarify code meaning