Fixes surrounding token replacement and pay key generation.