Change script loading method, add MAIN_SCRIPT constant