Updated thrift puprose and refactored it to make it cleaner.