Really fix the basename compat issues; use a for loop