cleaned up code. added modality to dialog windows.