Move communication stuff out of main