Assigning file name and fixing generation order.