Called removeStream whenever exiting a function that creates a out stream. Also merging linktest code.