Updating event handlers to be apart of the form

Cleaned up the code a little by having the events be generated with the
rest of the form to preserve them. Added functionality to test if
preferences have been changed and request confirmation before allowing
them.