fixed binarystream and moved it in its own file