     
     func writeBoolean(var value:Bool)
     {
-        data.appendBytes(&value, length: 1)
-        position++
+        range.location = position
+        range.length = 1
+        
+        data.replaceBytesInRange(range, withBytes: &value)
+        position += range.length
     }
     
     func writeDouble(var value:Double)
     {
-        let num = 8
+        range.location = position
+        range.length = 8
+        
         if endian == Endian.BIG_ENIDAN
         {
             var bytes = ByteArray.dump(value)
             bytes.reverse()
             
-            data.appendBytes(&bytes, length: bytes.count)
+            data.replaceBytesInRange(range, withBytes: &bytes)
         }
         else
         {
-            data.appendBytes(&value, length: num)
-        }
-        
-        position += num
+            data.replaceBytesInRange(range, withBytes: &value)
+        }
+        
+        position += range.length
     }
     
     func writeFloat(var value:Float32)
     {
-        let num = 4
+        range.location = position
+        range.length = 4
+        
         if endian == Endian.BIG_ENIDAN
         {
             var bytes = ByteArray.dump(value)
             bytes.reverse()
             
-            data.appendBytes(&bytes, length: bytes.count)
+            data.replaceBytesInRange(range, withBytes: &bytes)
         }
         else
         {
-            data.appendBytes(&value, length: num)
-        }
-        
-        position += num
+            data.replaceBytesInRange(range, withBytes: &value)
+        }
+        
+        position += range.length
     }
     
     func writeInt8(var value:Int8)
     {
-        data.appendBytes(&value, length: 1)
-        position++
+        range.location = position
+        range.length = 1
+        
+        data.replaceBytesInRange(range, withBytes: &value)
+        position += range.length
     }
     
     func writeInt16(var value:Int16)

            value = value.bigEndian
        }
        
        let num = 8
        data.appendBytes(&value, length: num)
        position += num
    }
    
    func writeUInt8(var value:UInt8)
    {
        data.appendBytes(&value, length: 1)
        position++
    }
    
    func writeUInt16(var value:UInt16)

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