Bug fixes, and add format_<period>