some fixes, reading from input stream instead of file