cleanup and keyscan