Clean up event handling for form submission

Let me know what you think!