Lot of small bug fixes related to date and average/detail switching