Move set_filename logic to after_initialize