Move stuff out of main