Fixed some bugs in the periodic update.