Fixed handling of keys.