code cleanup and hook up delete button functions