Replace recursive approach with iterative approach for readPacket()

Possible benefits:
- Less expensive function calls and stack space.
- Probably make it easier for compression implementation since the loop gonna work on the same buffer (uncompressed payload).