Reordered some JS events