Fix key derivation