Add support for traits/types

The way we are using amflib, we use typed objects.  We often read objects over the wire that come with a type, and then send them back to the origin server.  In order for that to work, we had to add these patches.  I apologize for the extra merge commits that come along with this.  Mostly I wanted to make sure we submitted it back so that folks can use it if they like.