clean up headers a bit, move engine code around