Fix onprestart bug