added key import/export. refactoring