Code for handling multiple frames per packet