Improved modal presentation and hide logic.