Fully implement encode/decode of all integers and table elements

This change is a fuller implementation of what you merged from someone else; it conflicts, but you haven't released that change, so I think you should drop it.  This is better done and more comprehensive.