[KMS] Fixed NRE in Toolkit.Init(); improved resource cleanup