fixes and refactoring for calendar
resolving conflicts