Fix crashes on orientation change

This fixes the crashes that occurred when a dialog was displayed during an
orientation change. Addresses #10.