Refactor ics calendar generation