diff --git a/src/libGLESv2/ProgramBinary.cpp b/src/libGLESv2/ProgramBinary.cpp
index 2aa3719..62576a5 100644
--- a/src/libGLESv2/ProgramBinary.cpp
+++ b/src/libGLESv2/ProgramBinary.cpp
@@ -31,7 +31,7 @@
 namespace gl
 {
 
-namespace 
+namespace
 {
 
 unsigned int ParseAndStripArrayIndex(std::string* name)
@@ -78,7 +78,7 @@
 
 }
 
-VariableLocation::VariableLocation(const std::string &name, unsigned int element, unsigned int index) 
+VariableLocation::VariableLocation(const std::string &name, unsigned int element, unsigned int index)
     : name(name), element(element), index(index)
 {
 }
@@ -275,7 +275,7 @@
 int ProgramBinary::getSemanticIndex(int attributeIndex)
 {
     ASSERT(attributeIndex >= 0 && attributeIndex < MAX_VERTEX_ATTRIBS);
-    
+
     return mSemanticIndex[attributeIndex];
 }
 
@@ -376,7 +376,7 @@
             const int index = mUniformIndex[location].index;
             const bool isArray = mUniforms[index]->isArray();
 
-            if ((isArray && mUniformIndex[location].element == subscript) || 
+            if ((isArray && mUniformIndex[location].element == subscript) ||
                 (subscript == GL_INVALID_INDEX))
             {
                 return location;
@@ -636,7 +636,7 @@
 }
 
 template <int cols, int rows>
-bool ProgramBinary::setUniformMatrixfv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value, GLenum targetUniformType) 
+bool ProgramBinary::setUniformMatrixfv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value, GLenum targetUniformType)
 {
     if (location < 0 || location >= (int)mUniformIndex.size())
     {
@@ -878,7 +878,7 @@
                 }
             }
             break;
-       
+
           case GL_UNSIGNED_INT:
             {
                 GLuint *uintParams = (GLuint*)targetUniform->data + mUniformIndex[location].element * 4;
@@ -889,7 +889,7 @@
                 }
             }
             break;
-          
+
           default: UNREACHABLE();
         }
     }
@@ -1065,18 +1065,15 @@
 {
     BinaryInputStream stream(binary, length);
 
-    int format = 0;
-    stream.read(&format);
+    int format = stream.readInt<int>();
     if (format != GL_PROGRAM_BINARY_ANGLE)
     {
         infoLog.append("Invalid program binary format.");
         return false;
     }
 
-    int majorVersion = 0;
-    int minorVersion = 0;
-    stream.read(&majorVersion);
-    stream.read(&minorVersion);
+    int majorVersion = stream.readInt<int>();
+    int minorVersion = stream.readInt<int>();
     if (majorVersion != ANGLE_MAJOR_VERSION || minorVersion != ANGLE_MINOR_VERSION)
     {
         infoLog.append("Invalid program binary version.");
@@ -1084,15 +1081,14 @@
     }
 
     unsigned char commitString[ANGLE_COMMIT_HASH_SIZE];
-    stream.read(commitString, ANGLE_COMMIT_HASH_SIZE);
+    stream.readBytes(commitString, ANGLE_COMMIT_HASH_SIZE);
     if (memcmp(commitString, ANGLE_COMMIT_HASH, sizeof(unsigned char) * ANGLE_COMMIT_HASH_SIZE) != 0)
     {
         infoLog.append("Invalid program binary version.");
         return false;
     }
 
-    int compileFlags = 0;
-    stream.read(&compileFlags);
+    int compileFlags = stream.readInt<int>();
     if (compileFlags != ANGLE_COMPILE_OPTIMIZATION_LEVEL)
     {
         infoLog.append("Mismatched compilation flags.");
@@ -1101,153 +1097,131 @@
 
     for (int i = 0; i < MAX_VERTEX_ATTRIBS; ++i)
     {
-        stream.read(&mLinkedAttribute[i].type);
-        std::string name;
-        stream.read(&name);
-        mLinkedAttribute[i].name = name;
-        stream.read(&mShaderAttributes[i].type);
-        stream.read(&mShaderAttributes[i].name);
-        stream.read(&mSemanticIndex[i]);
+        stream.readInt(&mLinkedAttribute[i].type);
+        stream.readString(&mLinkedAttribute[i].name);
+        stream.readInt(&mShaderAttributes[i].type);
+        stream.readString(&mShaderAttributes[i].name);
+        stream.readInt(&mSemanticIndex[i]);
     }
 
     initAttributesByLayout();
 
     for (unsigned int i = 0; i < MAX_TEXTURE_IMAGE_UNITS; ++i)
     {
-        stream.read(&mSamplersPS[i].active);
-        stream.read(&mSamplersPS[i].logicalTextureUnit);
-        
-        int textureType;
-        stream.read(&textureType);
-        mSamplersPS[i].textureType = (TextureType) textureType;
+        stream.readBool(&mSamplersPS[i].active);
+        stream.readInt(&mSamplersPS[i].logicalTextureUnit);
+        stream.readInt(&mSamplersPS[i].textureType);
     }
 
     for (unsigned int i = 0; i < IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS; ++i)
     {
-        stream.read(&mSamplersVS[i].active);
-        stream.read(&mSamplersVS[i].logicalTextureUnit);
-        
-        int textureType;
-        stream.read(&textureType);
-        mSamplersVS[i].textureType = (TextureType) textureType;
+        stream.readBool(&mSamplersVS[i].active);
+        stream.readInt(&mSamplersVS[i].logicalTextureUnit);
+        stream.readInt(&mSamplersVS[i].textureType);
     }
 
-    stream.read(&mUsedVertexSamplerRange);
-    stream.read(&mUsedPixelSamplerRange);
-    stream.read(&mUsesPointSize);
-    stream.read(&mShaderVersion);
+    stream.readInt(&mUsedVertexSamplerRange);
+    stream.readInt(&mUsedPixelSamplerRange);
+    stream.readBool(&mUsesPointSize);
+    stream.readInt(&mShaderVersion);
 
-    size_t size;
-    stream.read(&size);
+    const unsigned int uniformCount = stream.readInt<unsigned int>();
     if (stream.error())
     {
         infoLog.append("Invalid program binary.");
         return false;
     }
 
-    mUniforms.resize(size);
-    for (unsigned int i = 0; i < size; ++i)
+    mUniforms.resize(uniformCount);
+    for (unsigned int uniformIndex = 0; uniformIndex < uniformCount; uniformIndex++)
     {
-        GLenum type;
-        GLenum precision;
-        std::string name;
-        unsigned int arraySize;
-        int blockIndex;
+        GLenum type = stream.readInt<GLenum>();
+        GLenum precision = stream.readInt<GLenum>();
+        std::string name = stream.readString();
+        unsigned int arraySize = stream.readInt<unsigned int>();
+        int blockIndex = stream.readInt<int>();
 
-        stream.read(&type);
-        stream.read(&precision);
-        stream.read(&name);
-        stream.read(&arraySize);
-        stream.read(&blockIndex);
-
-        int offset;
-        int arrayStride;
-        int matrixStride;
-        bool isRowMajorMatrix;
-
-        stream.read(&offset);
-        stream.read(&arrayStride);
-        stream.read(&matrixStride);
-        stream.read(&isRowMajorMatrix);
+        int offset = stream.readInt<int>();
+        int arrayStride = stream.readInt<int>();
+        int matrixStride = stream.readInt<int>();
+        bool isRowMajorMatrix = stream.readBool();
 
         const gl::BlockMemberInfo blockInfo(offset, arrayStride, matrixStride, isRowMajorMatrix);
 
-        mUniforms[i] = new LinkedUniform(type, precision, name, arraySize, blockIndex, blockInfo);
-        
-        stream.read(&mUniforms[i]->psRegisterIndex);
-        stream.read(&mUniforms[i]->vsRegisterIndex);
-        stream.read(&mUniforms[i]->registerCount);
-        stream.read(&mUniforms[i]->registerElement);
+        LinkedUniform *uniform = new LinkedUniform(type, precision, name, arraySize, blockIndex, blockInfo);
+
+        stream.readInt(&uniform->psRegisterIndex);
+        stream.readInt(&uniform->vsRegisterIndex);
+        stream.readInt(&uniform->registerCount);
+        stream.readInt(&uniform->registerElement);
+
+        mUniforms[uniformIndex] = uniform;
     }
 
-    stream.read(&size);
+    unsigned int uniformBlockCount = stream.readInt<unsigned int>();
     if (stream.error())
     {
         infoLog.append("Invalid program binary.");
         return false;
     }
 
-    mUniformBlocks.resize(size);
-    for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < size; ++uniformBlockIndex)
+    mUniformBlocks.resize(uniformBlockCount);
+    for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < uniformBlockCount; ++uniformBlockIndex)
     {
-        std::string name;
-        unsigned int elementIndex;
-        unsigned int dataSize;
+        std::string name = stream.readString();
+        unsigned int elementIndex = stream.readInt<unsigned int>();
+        unsigned int dataSize = stream.readInt<unsigned int>();
 
-        stream.read(&name);
-        stream.read(&elementIndex);
-        stream.read(&dataSize);
+        UniformBlock *uniformBlock = new UniformBlock(name, elementIndex, dataSize);
 
-        mUniformBlocks[uniformBlockIndex] = new UniformBlock(name, elementIndex, dataSize);
+        stream.readInt(&uniformBlock->psRegisterIndex);
+        stream.readInt(&uniformBlock->vsRegisterIndex);
 
-        UniformBlock& uniformBlock = *mUniformBlocks[uniformBlockIndex];
-        stream.read(&uniformBlock.psRegisterIndex);
-        stream.read(&uniformBlock.vsRegisterIndex);
-
-        size_t numMembers;
-        stream.read(&numMembers);
-        uniformBlock.memberUniformIndexes.resize(numMembers);
+        unsigned int numMembers = stream.readInt<unsigned int>();
+        uniformBlock->memberUniformIndexes.resize(numMembers);
         for (unsigned int blockMemberIndex = 0; blockMemberIndex < numMembers; blockMemberIndex++)
         {
-            stream.read(&uniformBlock.memberUniformIndexes[blockMemberIndex]);
+            stream.readInt(&uniformBlock->memberUniformIndexes[blockMemberIndex]);
         }
+
+        mUniformBlocks[uniformBlockIndex] = uniformBlock;
     }
 
-    stream.read(&size);
+    const unsigned int uniformIndexCount = stream.readInt<unsigned int>();
     if (stream.error())
     {
         infoLog.append("Invalid program binary.");
         return false;
     }
 
-    mUniformIndex.resize(size);
-    for (unsigned int i = 0; i < size; ++i)
+    mUniformIndex.resize(uniformIndexCount);
+    for (unsigned int uniformIndexIndex = 0; uniformIndexIndex < uniformIndexCount; uniformIndexIndex++)
     {
-        stream.read(&mUniformIndex[i].name);
-        stream.read(&mUniformIndex[i].element);
-        stream.read(&mUniformIndex[i].index);
+        stream.readString(&mUniformIndex[uniformIndexIndex].name);
+        stream.readInt(&mUniformIndex[uniformIndexIndex].element);
+        stream.readInt(&mUniformIndex[uniformIndexIndex].index);
     }
 
-    stream.read(&mTransformFeedbackBufferMode);
-    stream.read(&size);
-    mTransformFeedbackLinkedVaryings.resize(size);
-    for (size_t i = 0; i < mTransformFeedbackLinkedVaryings.size(); i++)
+    stream.readInt(&mTransformFeedbackBufferMode);
+    const unsigned int transformFeedbackVaryingCount = stream.readInt<unsigned int>();
+    mTransformFeedbackLinkedVaryings.resize(transformFeedbackVaryingCount);
+    for (unsigned int varyingIndex = 0; varyingIndex < transformFeedbackVaryingCount; varyingIndex++)
     {
-        LinkedVarying &varying = mTransformFeedbackLinkedVaryings[i];
+        LinkedVarying &varying = mTransformFeedbackLinkedVaryings[varyingIndex];
 
-        stream.read(&varying.name);
-        stream.read(&varying.type);
-        stream.read(&varying.size);
-        stream.read(&varying.semanticName);
-        stream.read(&varying.semanticIndex);
-        stream.read(&varying.semanticIndexCount);
+        stream.readString(&varying.name);
+        stream.readInt(&varying.type);
+        stream.readInt(&varying.size);
+        stream.readString(&varying.semanticName);
+        stream.readInt(&varying.semanticIndex);
+        stream.readInt(&varying.semanticIndexCount);
     }
 
-    stream.read(&mVertexHLSL);
-    stream.read(&mVertexWorkarounds);
+    stream.readString(&mVertexHLSL);
 
-    unsigned int vertexShaderCount;
-    stream.read(&vertexShaderCount);
+    stream.readInt(&mVertexWorkarounds);
+
+    const unsigned int vertexShaderCount = stream.readInt<unsigned int>();
 
     for (unsigned int vertexShaderIndex = 0; vertexShaderIndex < vertexShaderCount; vertexShaderIndex++)
     {
@@ -1256,14 +1230,13 @@
         for (size_t inputIndex = 0; inputIndex < MAX_VERTEX_ATTRIBS; inputIndex++)
         {
             VertexFormat *vertexInput = &inputLayout[inputIndex];
-            stream.read(&vertexInput->mType);
-            stream.read(&vertexInput->mNormalized);
-            stream.read(&vertexInput->mComponents);
-            stream.read(&vertexInput->mPureInteger);
+            stream.readInt(&vertexInput->mType);
+            stream.readInt(&vertexInput->mNormalized);
+            stream.readInt(&vertexInput->mComponents);
+            stream.readBool(&vertexInput->mPureInteger);
         }
 
-        unsigned int vertexShaderSize;
-        stream.read(&vertexShaderSize);
+        unsigned int vertexShaderSize = stream.readInt<unsigned int>();
 
         const char *vertexShaderFunction = (const char*) binary + stream.offset();
 
@@ -1287,8 +1260,7 @@
         stream.skip(vertexShaderSize);
     }
 
-    unsigned int pixelShaderSize;
-    stream.read(&pixelShaderSize);
+    unsigned int pixelShaderSize = stream.readInt<unsigned int>();
 
     const char *pixelShaderFunction = (const char*) binary + stream.offset();
     mPixelExecutable = mRenderer->loadExecutable(reinterpret_cast<const DWORD*>(pixelShaderFunction),
@@ -1301,8 +1273,7 @@
     }
     stream.skip(pixelShaderSize);
 
-    unsigned int geometryShaderSize;
-    stream.read(&geometryShaderSize);
+    unsigned int geometryShaderSize = stream.readInt<unsigned int>();
 
     if (geometryShaderSize > 0)
     {
@@ -1340,107 +1311,107 @@
 {
     BinaryOutputStream stream;
 
-    stream.write(GL_PROGRAM_BINARY_ANGLE);
-    stream.write(ANGLE_MAJOR_VERSION);
-    stream.write(ANGLE_MINOR_VERSION);
-    stream.write(ANGLE_COMMIT_HASH, ANGLE_COMMIT_HASH_SIZE);
-    stream.write(ANGLE_COMPILE_OPTIMIZATION_LEVEL);
+    stream.writeInt(GL_PROGRAM_BINARY_ANGLE);
+    stream.writeInt(ANGLE_MAJOR_VERSION);
+    stream.writeInt(ANGLE_MINOR_VERSION);
+    stream.writeBytes(reinterpret_cast<unsigned char*>(ANGLE_COMMIT_HASH), ANGLE_COMMIT_HASH_SIZE);
+    stream.writeInt(ANGLE_COMPILE_OPTIMIZATION_LEVEL);
 
     for (unsigned int i = 0; i < MAX_VERTEX_ATTRIBS; ++i)
     {
-        stream.write(mLinkedAttribute[i].type);
-        stream.write(mLinkedAttribute[i].name);
-        stream.write(mShaderAttributes[i].type);
-        stream.write(mShaderAttributes[i].name);
-        stream.write(mSemanticIndex[i]);
+        stream.writeInt(mLinkedAttribute[i].type);
+        stream.writeString(mLinkedAttribute[i].name);
+        stream.writeInt(mShaderAttributes[i].type);
+        stream.writeString(mShaderAttributes[i].name);
+        stream.writeInt(mSemanticIndex[i]);
     }
 
     for (unsigned int i = 0; i < MAX_TEXTURE_IMAGE_UNITS; ++i)
     {
-        stream.write(mSamplersPS[i].active);
-        stream.write(mSamplersPS[i].logicalTextureUnit);
-        stream.write((int) mSamplersPS[i].textureType);
+        stream.writeInt(mSamplersPS[i].active);
+        stream.writeInt(mSamplersPS[i].logicalTextureUnit);
+        stream.writeInt(mSamplersPS[i].textureType);
     }
 
     for (unsigned int i = 0; i < IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS; ++i)
     {
-        stream.write(mSamplersVS[i].active);
-        stream.write(mSamplersVS[i].logicalTextureUnit);
-        stream.write((int) mSamplersVS[i].textureType);
+        stream.writeInt(mSamplersVS[i].active);
+        stream.writeInt(mSamplersVS[i].logicalTextureUnit);
+        stream.writeInt(mSamplersVS[i].textureType);
     }
 
-    stream.write(mUsedVertexSamplerRange);
-    stream.write(mUsedPixelSamplerRange);
-    stream.write(mUsesPointSize);
-    stream.write(mShaderVersion);
+    stream.writeInt(mUsedVertexSamplerRange);
+    stream.writeInt(mUsedPixelSamplerRange);
+    stream.writeInt(mUsesPointSize);
+    stream.writeInt(mShaderVersion);
 
-    stream.write(mUniforms.size());
+    stream.writeInt(mUniforms.size());
     for (size_t uniformIndex = 0; uniformIndex < mUniforms.size(); ++uniformIndex)
     {
         const LinkedUniform &uniform = *mUniforms[uniformIndex];
 
-        stream.write(uniform.type);
-        stream.write(uniform.precision);
-        stream.write(uniform.name);
-        stream.write(uniform.arraySize);
-        stream.write(uniform.blockIndex);
+        stream.writeInt(uniform.type);
+        stream.writeInt(uniform.precision);
+        stream.writeString(uniform.name);
+        stream.writeInt(uniform.arraySize);
+        stream.writeInt(uniform.blockIndex);
 
-        stream.write(uniform.blockInfo.offset);
-        stream.write(uniform.blockInfo.arrayStride);
-        stream.write(uniform.blockInfo.matrixStride);
-        stream.write(uniform.blockInfo.isRowMajorMatrix);
+        stream.writeInt(uniform.blockInfo.offset);
+        stream.writeInt(uniform.blockInfo.arrayStride);
+        stream.writeInt(uniform.blockInfo.matrixStride);
+        stream.writeInt(uniform.blockInfo.isRowMajorMatrix);
 
-        stream.write(uniform.psRegisterIndex);
-        stream.write(uniform.vsRegisterIndex);
-        stream.write(uniform.registerCount);
-        stream.write(uniform.registerElement);
+        stream.writeInt(uniform.psRegisterIndex);
+        stream.writeInt(uniform.vsRegisterIndex);
+        stream.writeInt(uniform.registerCount);
+        stream.writeInt(uniform.registerElement);
     }
 
-    stream.write(mUniformBlocks.size());
+    stream.writeInt(mUniformBlocks.size());
     for (size_t uniformBlockIndex = 0; uniformBlockIndex < mUniformBlocks.size(); ++uniformBlockIndex)
     {
         const UniformBlock& uniformBlock = *mUniformBlocks[uniformBlockIndex];
 
-        stream.write(uniformBlock.name);
-        stream.write(uniformBlock.elementIndex);
-        stream.write(uniformBlock.dataSize);
+        stream.writeString(uniformBlock.name);
+        stream.writeInt(uniformBlock.elementIndex);
+        stream.writeInt(uniformBlock.dataSize);
 
-        stream.write(uniformBlock.memberUniformIndexes.size());
+        stream.writeInt(uniformBlock.memberUniformIndexes.size());
         for (unsigned int blockMemberIndex = 0; blockMemberIndex < uniformBlock.memberUniformIndexes.size(); blockMemberIndex++)
         {
-            stream.write(uniformBlock.memberUniformIndexes[blockMemberIndex]);
+            stream.writeInt(uniformBlock.memberUniformIndexes[blockMemberIndex]);
         }
 
-        stream.write(uniformBlock.psRegisterIndex);
-        stream.write(uniformBlock.vsRegisterIndex);
+        stream.writeInt(uniformBlock.psRegisterIndex);
+        stream.writeInt(uniformBlock.vsRegisterIndex);
     }
 
-    stream.write(mUniformIndex.size());
+    stream.writeInt(mUniformIndex.size());
     for (size_t i = 0; i < mUniformIndex.size(); ++i)
     {
-        stream.write(mUniformIndex[i].name);
-        stream.write(mUniformIndex[i].element);
-        stream.write(mUniformIndex[i].index);
+        stream.writeString(mUniformIndex[i].name);
+        stream.writeInt(mUniformIndex[i].element);
+        stream.writeInt(mUniformIndex[i].index);
     }
 
-    stream.write(mTransformFeedbackBufferMode);
-    stream.write(mTransformFeedbackLinkedVaryings.size());
+    stream.writeInt(mTransformFeedbackBufferMode);
+    stream.writeInt(mTransformFeedbackLinkedVaryings.size());
     for (size_t i = 0; i < mTransformFeedbackLinkedVaryings.size(); i++)
     {
         const LinkedVarying &varying = mTransformFeedbackLinkedVaryings[i];
 
-        stream.write(varying.name);
-        stream.write(varying.type);
-        stream.write(varying.size);
-        stream.write(varying.semanticName);
-        stream.write(varying.semanticIndex);
-        stream.write(varying.semanticIndexCount);
+        stream.writeString(varying.name);
+        stream.writeInt(varying.type);
+        stream.writeInt(varying.size);
+        stream.writeString(varying.semanticName);
+        stream.writeInt(varying.semanticIndex);
+        stream.writeInt(varying.semanticIndexCount);
     }
 
-    stream.write(mVertexHLSL);
-    stream.write(mVertexWorkarounds);
+    stream.writeString(mVertexHLSL);
+    stream.writeInt(mVertexWorkarounds);
 
-    stream.write(mVertexExecutables.size());
+    stream.writeInt(mVertexExecutables.size());
     for (size_t vertexExecutableIndex = 0; vertexExecutableIndex < mVertexExecutables.size(); vertexExecutableIndex++)
     {
         VertexExecutable *vertexExecutable = mVertexExecutables[vertexExecutableIndex];
@@ -1448,32 +1419,32 @@
         for (size_t inputIndex = 0; inputIndex < gl::MAX_VERTEX_ATTRIBS; inputIndex++)
         {
             const VertexFormat &vertexInput = vertexExecutable->inputs()[inputIndex];
-            stream.write(vertexInput.mType);
-            stream.write(vertexInput.mNormalized);
-            stream.write(vertexInput.mComponents);
-            stream.write(vertexInput.mPureInteger);
+            stream.writeInt(vertexInput.mType);
+            stream.writeInt(vertexInput.mNormalized);
+            stream.writeInt(vertexInput.mComponents);
+            stream.writeInt(vertexInput.mPureInteger);
         }
 
-        UINT vertexShaderSize = vertexExecutable->shaderExecutable()->getLength();
-        stream.write(vertexShaderSize);
+        size_t vertexShaderSize = vertexExecutable->shaderExecutable()->getLength();
+        stream.writeInt(vertexShaderSize);
 
         unsigned char *vertexBlob = static_cast<unsigned char *>(vertexExecutable->shaderExecutable()->getFunction());
-        stream.write(vertexBlob, vertexShaderSize);
+        stream.writeBytes(vertexBlob, vertexShaderSize);
     }
 
-    UINT pixelShaderSize = mPixelExecutable->getLength();
-    stream.write(pixelShaderSize);
+    size_t pixelShaderSize = mPixelExecutable->getLength();
+    stream.writeInt(pixelShaderSize);
 
     unsigned char *pixelBlob = static_cast<unsigned char *>(mPixelExecutable->getFunction());
-    stream.write(pixelBlob, pixelShaderSize);
+    stream.writeBytes(pixelBlob, pixelShaderSize);
 
-    UINT geometryShaderSize = (mGeometryExecutable != NULL) ? mGeometryExecutable->getLength() : 0;
-    stream.write(geometryShaderSize);
+    size_t geometryShaderSize = (mGeometryExecutable != NULL) ? mGeometryExecutable->getLength() : 0;
+    stream.writeInt(geometryShaderSize);
 
     if (mGeometryExecutable != NULL && geometryShaderSize > 0)
     {
         unsigned char *geometryBlob = static_cast<unsigned char *>(mGeometryExecutable->getFunction());
-        stream.write(geometryBlob, geometryShaderSize);
+        stream.writeBytes(geometryBlob, geometryShaderSize);
     }
 
     GUID identifier = mRenderer->getAdapterIdentifier();
@@ -1985,7 +1956,7 @@
     if (IsSampler(constant.type))
     {
         unsigned int samplerIndex = constant.registerIndex;
-            
+
         do
         {
             if (shader == GL_VERTEX_SHADER)
@@ -2352,7 +2323,7 @@
     return true;
 }
 
-bool ProgramBinary::isValidated() const 
+bool ProgramBinary::isValidated() const
 {
     return mValidated;
 }
@@ -2620,7 +2591,7 @@
         if (mSamplersPS[i].active)
         {
             unsigned int unit = mSamplersPS[i].logicalTextureUnit;
-            
+
             if (unit >= maxCombinedTextureImageUnits)
             {
                 if (infoLog)
@@ -2655,7 +2626,7 @@
         if (mSamplersVS[i].active)
         {
             unsigned int unit = mSamplersVS[i].logicalTextureUnit;
-            
+
             if (unit >= maxCombinedTextureImageUnits)
             {
                 if (infoLog)
