applied init_main patch