Small fixes to key.py