Fixed a crash caused by opening a document.
Add mouse hooks on a separate thread.
Make keyboard hooks a little less likely to disconnect.