Fix scope key generation