Refactored code, changed logic for refreshing tokens, removed unnecessary api calls (we use context now).