Some modal loop code cleanups.
Fixes for ActiveX window embedding.