Replace std::pairs with std::tuples
Let's use WaitForInputIdle instead of busy-looping