Added logging and page-redirecting for various exceptions.Alsoadded some basic input validation.