Added working thrift RPC interface and fixed bug in exiting