Cleaned up the code that I made messy trying to get calendar to work.