Optimize reading from network stream