Encoding and decoding now work for all types