Implement app-level flow control, solve memory leak.