Some minor refactoring and setup scheduled task for refresh_access_token