Refactor code out of forms into datagrid classes