Added buffer and packetloop function.