Use new packet reading API, fixes a memory leak.