move transport code into separate file