This actually almost works perfectly.

Todo:
- 2s compliment for type 0 and 1
- citing sources
- figure out why not everything gets written to the output