Removed unecessary code in decode.
Added encoding and proof of concept.