bug fixes + key handling