Various changes to greatly improve speed of socket communication.