Code cleanup and change read timeout to infinite.