Some bug fixes.

I made some bug fixes and a short review on the use of FileInputStream.