Thrift implementation and lots of other stuff