Small changes to key logic