Fixed a lot of errors; Made dialog a template class