Finished writing the encode, decode functions.