Refactored the way the key and token are set.