optimized the implementation of keys.
Merge branch 'keys' into my_branches