Minor refactor to use objects instead of globals