Added legend to calendar view and fixed a bug