Fix key handling