Slight refactor of date handling and more strict error checking