more incremental fixes (library loading, input stream returns -1 at end)