Use Stream instead of byte array access