Complete rewrite of gcal.py so functions are reusable