Better handling of file groups.

Grouping files by base name when processing, fixes #42.