A little cleanup & fix potential InputStream closing issue