Minor refactor + bug fix for out-of-range dates