WIP Refactoring the calendar js class and working out various bugs