Make sure total_sleep is initialized.
Allow the template source to be customized.