Many fixes in counting.

FIXME: uncomment block to count properly on the weekend. Commented for
testing.
Some lag in switching periods observed.