add Reply object and fix memory leaks