 public let dateDesc = NSSortDescriptor(key: HKSampleSortIdentifierStartDate, ascending: false)
 public let lastChartsDataCacheKey = "lastChartsDataCacheKey"
 
-public typealias HMAuthorizationBlock  = (success: Bool, error: NSError?) -> Void
-public typealias HMSampleBlock         = (samples: [MCSample], error: NSError?) -> Void
-public typealias HMTypedSampleBlock    = (samples: [HKSampleType: [MCSample]], error: NSError?) -> Void
-public typealias HMAggregateBlock      = (aggregates: AggregateQueryResult, error: NSError?) -> Void
-public typealias HMCorrelationBlock    = ([MCSample], [MCSample], NSError?) -> Void
-
-public typealias HMCircadianBlock          = (intervals: [(NSDate, CircadianEvent)], error: NSError?) -> Void
-public typealias HMCircadianAggregateBlock = (aggregates: [(NSDate, Double)], error: NSError?) -> Void
-public typealias HMCircadianCategoryBlock  = (categories: [Int:Double], error: NSError?) -> Void
-public typealias HMFastingCorrelationBlock = ([(NSDate, Double, MCSample)], NSError?) -> Void
-
-public typealias HMAnchorQueryBlock    = (HKAnchoredObjectQuery, [HKSample]?, [HKDeletedObject]?, HKQueryAnchor?, NSError?) -> Void
-public typealias HMAnchorSamplesBlock  = (added: [HKSample], deleted: [HKDeletedObject], newAnchor: HKQueryAnchor?, error: NSError?) -> Void
-public typealias HMAnchorSamplesCBlock = (added: [HKSample], deleted: [HKDeletedObject], newAnchor: HKQueryAnchor?, error: NSError?, completion: () -> Void) -> Void
-
-public typealias HMAggregateCache = Cache<MCAggregateArray>
-
-// Constants and enums.
 public let HMErrorDomain                        = "HMErrorDomain"
 public let HMSampleTypeIdentifierSleepDuration  = "HMSampleTypeIdentifierSleepDuration"
 

    public static let sharedManager = MCHealthManager()

    public lazy var healthKitStore: HKHealthStore = HKHealthStore()
    public var mostRecentSamples = [HKSampleType: [MCSample]]()
    public var aggregateCache: HMAggregateCache

    public override init() {
        do {
            self.aggregateCache = try HMAggregateCache(name: "HMAggregateCache")
        } catch _ {
            fatalError("Unable to create HealthManager aggregate cache.")

import AwesomeCache
import SwiftyBeaver

// Typealiases
public typealias HMAuthorizationBlock  = (success: Bool, error: NSError?) -> Void
public typealias HMSampleBlock         = (samples: [MCSample], error: NSError?) -> Void
public typealias HMTypedSampleBlock    = (samples: [HKSampleType: [MCSample]], error: NSError?) -> Void
public typealias HMAggregateBlock      = (aggregates: AggregateQueryResult, error: NSError?) -> Void
public typealias HMCorrelationBlock    = ([MCSample], [MCSample], NSError?) -> Void

public typealias HMCircadianBlock          = (intervals: [(NSDate, CircadianEvent)], error: NSError?) -> Void
public typealias HMCircadianAggregateBlock = (aggregates: [(NSDate, Double)], error: NSError?) -> Void
public typealias HMCircadianCategoryBlock  = (categories: [Int:Double], error: NSError?) -> Void
public typealias HMFastingCorrelationBlock = ([(NSDate, Double, MCSample)], NSError?) -> Void

public typealias HMAnchorQueryBlock    = (HKAnchoredObjectQuery, [HKSample]?, [HKDeletedObject]?, HKQueryAnchor?, NSError?) -> Void
public typealias HMAnchorSamplesBlock  = (added: [HKSample], deleted: [HKDeletedObject], newAnchor: HKQueryAnchor?, error: NSError?) -> Void
public typealias HMAnchorSamplesCBlock = (added: [HKSample], deleted: [HKDeletedObject], newAnchor: HKQueryAnchor?, error: NSError?, completion: () -> Void) -> Void

public typealias HMAggregateCache = Cache<MCAggregateArray>

// Constants and enums.
public let refDate  = NSDate(timeIntervalSinceReferenceDate: 0)
public let noAnchor = HKQueryAnchor(fromValue: Int(HKAnchoredObjectQueryNoAnchor))
public let noLimit  = Int(HKObjectQueryNoLimit)
