Modified flush to wait till tx is complete. Added flush_rx with same functionality as old flush