Updated app logic to prevent name collisions in the archive (especially when using flatten option). Added test to check new logic and option behavior.