Added documentation to encoding and decoding