using better dialog to display output. also starting code cleanup.