Fix bug in automatic refresh.