     
     // #pragma mark - read/write header
     
+    // TODO: similar code for read data and read header (no added value)
+    
     func readHeader() -> H! {
         
-        let data = self.fileHandle.readDataOfLength(sizeof(H))
-        
-        // works only by value?
-        if data {
-            var result = H()
-            
+        let data : NSData! = readHeader()
+        
+        if (data != nil) {
+            
+            var result : H! = nil
+            
+            // TODO: how to read data from NSData to a value variable?
             data.getBytes(&result)
             
             return result

    public func readBlock(index : UID) -> D! {
        self.seekToFileID(index)
        
        let header = readHeader()
        if (header.used) {
            return self.readData()
        }

            
            let pos = calculatePos(index)
            
            if (newValue != nil) {
                if (pos > endOfFile) {
                    // TODO: error
                } else {
