Persistent object

Refactored project to utilise persistent objects instead of directly manipulating globals.