Make input streams buffered and close them after use

Several input streams were unbuffered and others were not closed
after use.

This fix has taken one to two seconds off a simple srmPing invocation.