Added SwapIOStream for stream.Wrapper, added entry point for decoding and refactored decoding logic