Added initial preparations for InputStream. This might (read does) contain many errors.