calendar/bp: sort dates and cleanup code