code cleanup and added custom error messages to forms