             value = value.bigEndian
         }
         
-        let num = 4
-        data.appendBytes(&value, length: num)
-        position += num
+        range.location = position
+        range.length = 4
+        
+        data.replaceBytesInRange(range, withBytes: &value)
+        position += range.length
     }
     
     func writeInt64(var value:Int)

            value = value.bigEndian
        }
        
        let num = 2
        data.appendBytes(&value, length: num)
        position += num
    }
    
    func writeInt32(var value:Int32)

        length = length == 0 ? remain : min(length, remain)
        if length > 0
        {
            let bin = bytes.data.subdataWithRange(NSRange(location: offset, length: length))
            
            var bytes = [UInt8](count: bin.length, repeatedValue: 0)
            bin.getBytes(&bytes, length: bytes.count)
            
            range.location = position
            range.length = bin.length
            
            data.replaceBytesInRange(range, withBytes: &bytes)
            position += range.length
        }
    }
}