[Windows] Refactor and cleanup debug logging in kmtip; fix return value bug in initialising preserved keys