First round of changes

- fix several issues in `Key`
- code cleanup

probably more changes to come in a further PR