Added fns, improved tcp