fixed many bugs in the scheduling of the daytime and nighttime refresh