Removed all end_phase2() code to Lua