         }
     }
     
+    
+    //MARK: Threads management
+    
+    /**
+    Hackish!
+    if a class has a generic T, and a method has another generic T (or even with another name)
+    and considering that the map function is defined to return a generic T.
+    If you want to map inside that method, you are going to have a bad time.
+    This method is a wrapper of the map function to work with all the generic mess.
+    
+    NOTE: not used for the moment, leave it here in case we need it.
+    
+    :param: items Array of items to map, they should be of type T (defined by the class)
+    if the items are not T, this will crash.
+    
+    :returns: Array of mapped items (they should be U, defined by the class)
+    */
+    func executeOnCorrectThread(block: ()->()) {
+        _test ? dispatch_sync(backgroundQueue, block) : dispatch_async(backgroundQueue, block)
+    }
+    
+    func executeOnMainThread(block: ()->()) {
+        if NSThread.currentThread().isMainThread {
+            block()
+        }
+        else {
+            dispatch_async(dispatch_get_main_queue(), block)
+        }
+    }
+    
 }

    NOTE2: Realm does not support sorting by KeyPaths, so you must only use properties of the model
    you want to fetch and not KeyPath to any relationship
    
    :param: request        Request to fetch objects
    :param: sectionKeyPath KeyPath to group the results by sections
    :param: mapper         Mapper to map the results.
    
    :returns: Self
    */
    public init(request: RealmRequest<T>, sectionKeyPath: String? ,mapper: (T)->(U)) throws {
        self.request = request

        }
    }
    
    private convenience init(forTESTRequest request: RealmRequest<T>, sectionKeyPath: String?, mapper: (T)->(U)) throws {
        try self.init(request: request, sectionKeyPath: sectionKeyPath, mapper: mapper)
        self._test = true
    }
    
    
    //MARK: Fetch
    
    /**
    Fetches the initial data for the RealmResultsController
    
    Atention: Must be called after creating
    
    - returns: [RealmSection<U>]
    */
    public func performFetch() -> [RealmSection<U>] {
        populating = true
        let objects = self.request.execute().toArray(T.self).map(getMirror)
