Fix handling empty dirs and absence of streams