Add function periods.base.
Improve variable names and comments.