preliminary streamIn streamOut and getProtection code