Improvements to encoding and decoding

Encoding should be faster, because it happens while constructing the proplist.

I also cleaned up the code quite a bit (no more try/catch. YAY).