Lots of changes for encoding/decoding more objects