Use group_by
Calculate ages on dates accurately
Minor refactoring
Simplify code structure by using nested modules and a constant