 
     func convertImage(input: UIImage, completionHandler handler: ImageHandler) {
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
-            var ASCIIGridWidth = self.gridWidth(input.size.width)
-            var output = self.convertImage(input, withFont: self.font, bgColor: self.backgroundColor, columns: ASCIIGridWidth, reversed: self.reversedLuminance, colorMode: self.colorMode)
+            let gridWidth = self.gridWidth(input.size.width)
+            let output = self.convertImage(input, withFont: self.font, bgColor: self.backgroundColor, columns: gridWidth, reversed: self.reversedLuminance, colorMode: self.colorMode)
             dispatch_async(dispatch_get_main_queue()) { handler?(output) }
         }
     }
 
     func convertToString(input: UIImage, completionHandler handler: StringHandler) {
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), {
-            var output = self.convertToString(input)
+            let output = self.convertToString(input)
             dispatch_async(dispatch_get_main_queue(), { handler?(output) })
         })
     }
 
     func convertImage(input: UIImage) -> UIImage {
-        var ASCIIGridWidth = gridWidth(input.size.width)
-        var output = convertImage(input, withFont: font, bgColor: backgroundColor, columns: ASCIIGridWidth, reversed: reversedLuminance, colorMode: colorMode)
+        let gridWidth = self.gridWidth(input.size.width)
+        let output = convertImage(input, withFont: font, bgColor: backgroundColor, columns: gridWidth, reversed: reversedLuminance, colorMode: colorMode)
         return output
     }
 
     func convertImage(input: UIImage, withFont font: UIFont, bgColor: UIColor, columns: Int, reversed: Bool, colorMode: ColorMode) -> UIImage {
         let opaque = !isTransparent()
-        let fontSize = font.pointSize
-        var ASCIIGridWidth = columns
-        var scaledImage = downscaleImage(input, withFactor: ASCIIGridWidth)
-        var pixelGrid = pixelGridForImage(scaledImage)
+        _ = font.pointSize
+        let gridWidth = columns
+        let scaledImage = downscaleImage(input, withFactor: gridWidth)
+        let pixelGrid = pixelGridForImage(scaledImage)
         UIGraphicsBeginImageContextWithOptions(input.size, false, 0.0)
 
         // Setup background

        if scaleFactor > min(image.size.height, image.size.width) {
            scaleFactor = min(image.size.height, image.size.width)
        }
        var ratio = scaleFactor / image.size.width
        var newWidth = scaleFactor
        var newHeight = ratio * image.size.height
        var size = CGSize(width: newWidth, height: newHeight)
        UIGraphicsBeginImageContextWithOptions(size, true, 1.0)
        image.drawInRect(CGRect(x: 0, y: 0, width: newWidth, height: newHeight))
        var scaledImage = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return scaledImage
    }

    }

    private func pixelGridForImage(image: UIImage) -> BlockGrid {
        let imageRef = image.CGImage!
        let width = CGImageGetWidth(imageRef)
        let height = CGImageGetHeight(imageRef)
        let colorSpace = CGColorSpaceCreateDeviceRGB()
        let rawData = UnsafeMutablePointer<UInt8>(malloc(height * width * 4))
        let bytesPerPixel = 4
        let bytesPerRow = bytesPerPixel * width
        let bitsPerComponent = 8

        let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.PremultipliedLast.rawValue | CGBitmapInfo.ByteOrder32Big.rawValue)
        let context = CGBitmapContextCreate(rawData, width, height, bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo.rawValue)
        CGContextDrawImage(context, CGRect(x: 0, y: 0, width: width, height: height), imageRef)
        let grid = BlockGrid(width: width, height: height)
        for row in 0..<height {
            for col in 0..<width {
                let byteIndex = (bytesPerRow * row) + col * bytesPerPixel
                let r = Double(rawData[byteIndex]) / 255.0
                let g = Double(rawData[byteIndex + 1]) / 255.0
                let b = Double(rawData[byteIndex + 2]) / 255.0
