Mark directories as order-only prerequisites.
Refactoring

Return lists instead of strings from lower-level routines, and remove some
unnecessary local variable declarations and assignments.