Fixed major bug in scan_dir and corrected some documentation.