Refactored most of the dialog button click listeners.