Added some encoding/decoding stuff.