     
     
     public enum LOAD_AVG {
-        /**
-        5, 30, 60 second samples
-        */
+        /// 5, 30, 60 second samples
         case SHORT
         
-        /**
-        1, 5, 15 minute samples
-        */
+        /// 1, 5, 15 minute samples
         case LONG
     }
     
     
     //--------------------------------------------------------------------------
+    // MARK: PRIVATE PROPERTIES
+    //--------------------------------------------------------------------------
+    
+    
+    private var loadPrevious: host_cpu_load_info = host_cpu_load_info(cpu_ticks:
+                                                                      (0,0,0,0))
+    
+    
+    //--------------------------------------------------------------------------
     // MARK: INITIALIZERS
     //--------------------------------------------------------------------------
     
     
-    public init() {
-        host = mach_host_self()
-        pset = 0
-        
-        libport = mach_host_self()
-        
-        let result = processor_set_default(host, &pset)
-        
-//        if (result != KERN_SUCCESS) {
-//            #if DEBUG
-//                println("ERROR: System class faild to init - \(result)")
-//            #endif
-//        }
-    }
-
+    public init() { }
+    
     
     //--------------------------------------------------------------------------
     // MARK: PUBLIC METHODS
     //--------------------------------------------------------------------------
     
     
-    /**
-    Close/cleanup.
-    
-    TODO: Can deinit do this?
-    */
-    public func fini() -> kern_return_t {
-        return mach_port_deallocate(mach_task_self_, host)
-    }
-    
-    
-    //--------------------------------------------------------------------------
-    // MARK: PUBLIC METHODS - SYSTEM
-    //--------------------------------------------------------------------------
-    
-    
-    public func physicalCores() -> Int {
-        return Int(hostBasicInfo().physical_cpu)
-    }
-    
-    
-    public func logicalCores() -> Int {
-        return Int(hostBasicInfo().logical_cpu)
-    }
-    
-    
-    /**
-    Get the current system CPU usage.
-    */
-    public func CPUUsage() -> (system: Double, user: Double, idle: Double,
-                                                             nice: Double) {
-            
-        if (load_prev == nil) {
-            println("FIRST CALL")
-            load_prev = hostCPULoadInfo()
-            sleep(1)
-        }
-        
-        let load = hostCPULoadInfo()
-        
-        // Can't use supscript on tuple
-        let user_diff = Double(load.cpu_ticks.0 - load_prev!.cpu_ticks.0)
-        let sys_diff  = Double(load.cpu_ticks.1 - load_prev!.cpu_ticks.1)
-        let idle_diff = Double(load.cpu_ticks.2 - load_prev!.cpu_ticks.2)
-        let nice_diff = Double(load.cpu_ticks.3 - load_prev!.cpu_ticks.3)
-        
-        
-        let totalTicks = sys_diff + user_diff + nice_diff + idle_diff
-        
-        var sys  = sys_diff  / totalTicks * 100
-        var user = user_diff / totalTicks * 100
-        var idle = idle_diff / totalTicks * 100
-        var nice = nice_diff / totalTicks * 100
-        
-        load_prev = load
+    public mutating func usageCPU() -> (system : Double,
+                                        user   : Double,
+                                        idle   : Double,
+                                        nice   : Double) {
+        let load = System.hostCPULoadInfo()
+        
+        let userDiff = Double(load.cpu_ticks.0 - loadPrevious.cpu_ticks.0)
+        let sysDiff  = Double(load.cpu_ticks.1 - loadPrevious.cpu_ticks.1)
+        let idleDiff = Double(load.cpu_ticks.2 - loadPrevious.cpu_ticks.2)
+        let niceDiff = Double(load.cpu_ticks.3 - loadPrevious.cpu_ticks.3)
+        
+        let totalTicks = sysDiff + userDiff + niceDiff + idleDiff
+        
+        let sys  = sysDiff  / totalTicks * 100.0
+        let user = userDiff / totalTicks * 100.0
+        let idle = idleDiff / totalTicks * 100.0
+        let nice = niceDiff / totalTicks * 100.0
+        
+        loadPrevious = load
         
         // TODO: 2 decimal places
         // TODO: Check that total is 100%

        
        return data
    }
    
    
    public func hostSchedInfo() -> host_sched_info {
        var size = HOST_SCHED_INFO_COUNT
        
        var hi = host_info_t.alloc(Int(HOST_SCHED_INFO_COUNT))
        hi.initialize(0)
        
        let result = host_info(mach_host_self(), HOST_SCHED_INFO, hi, &size)
        
        if (result != KERN_SUCCESS) {
            println("ERROR: \(__FUNCTION__) - \(result)")
            
            // TODO: Whats timeout?
            return host_sched_info(min_timeout: 0, min_quantum: 0)
        }
        
        let data = UnsafePointer<host_sched_info>(hi).memory
        
        hi.dealloc(Int(HOST_SCHED_INFO_COUNT))
        
        return data
    }
    
    
    private func hostLoadInfo() -> host_load_info {
        //        - Can get stat from cl with w or uptime as well
        //        - getloadavg()
        //        http://en.wikipedia.org/wiki/Load_(computing)
        
        var size = HOST_LOAD_INFO_COUNT
        var hi = host_info_t.alloc(Int(HOST_LOAD_INFO_COUNT))

                       UInt32(sizeof(host_load_info_data_t) / sizeof(integer_t))
private let HOST_CPU_LOAD_INFO_COUNT      : mach_msg_type_number_t =
                   UInt32(sizeof(host_cpu_load_info_data_t) / sizeof(integer_t))
private let HOST_VM_INFO64_COUNT          : mach_msg_type_number_t =
                      UInt32(sizeof(vm_statistics64_data_t) / sizeof(integer_t))
private let HOST_SCHED_INFO_COUNT         : mach_msg_type_number_t =
                      UInt32(sizeof(host_sched_info_data_t) / sizeof(integer_t))
private let PROCESSOR_SET_LOAD_INFO_COUNT : mach_msg_type_number_t =
              UInt32(sizeof(processor_set_load_info_data_t) / sizeof(natural_t))


public struct System {
    
    //--------------------------------------------------------------------------
    // MARK: PUBLIC PROPERTIES
    //--------------------------------------------------------------------------
    
    
    /**
    System page size.
    
    - Can check this via pagesize shell command as well
    - C lib function getpagesize()
    - host_page_size()
    
    TODO: This should be static right?
    */
    public static let PAGE_SIZE = vm_kernel_page_size
    
    
    //--------------------------------------------------------------------------
