Migrate to circular IO buffers

Homogenizes data format approach with supporting packages, reducing mallocs etc.

packethandler.c still needs some work to prevent an overflow of the output buffer.