codec: improve decode performance by calling ReadByte if Reader is io.ByteReader, and other misc optimizations.

Also include other misc optimizations and clean up of comments.

Improves RPC performance as seen in #9 .