Refactored InputStream. Cleaned code.