Removed use of globals, moved to  object for storage.