Attempt to fix some mouse issues

Attempt to fix some mouse issues with mosh!  

According to my testing, #566 is fixed with these changes, and #505 should be fixed too.

If you are having mouse issues, it would be great if you could help test this PR.