Add beforeShow and beforeHide events to gate. Minor UI improvements.