less crashy wave, rewrite error handling, don't include chars in function call to flush