             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 = 8
        data.appendBytes(&value, length: num)
        position += num
    }
    
    func writeUTF(var value:String)

            value = value.bigEndian
        }
        
        range.location = position
        range.length = 4
        
        data.replaceBytesInRange(range, withBytes: &value)
        position += range.length
    }
    
    func writeUInt64(var value:UInt64)
