Clean up templating and add form input validation.