Minor performance fixes in class key generation.