some fixing in keys initializing
some fix in leaving.... it doesn't work yet...