Modifications to client and server for second algorithm, possibly broken changes.