clean up channel impl
simplify channel logic. fix race condition in unbuffered mode.