Datetime support and better encoding and decoding