Add db.PurgeOrphanFolders() functionality
Fix folder scanning, add orphan scanning for folders