move init stuff out of main