Remove unused code.
Add delay to make sure send is complete and replace init() => pattern_init().

And ensure pattern_init() is called at setup time.