Moving all networking code so we can have a dedicated listen thread