some more cleanup and buggy keys handling