Refactored stream code

Refactored the stream code to make the KLVStream tidier and extendible