finish output streams and remove more C code