 bundledPlugins = null
 # Regexp for matching post filenames
 postMask = null
-# Global handle for current content being converted
-currentState = null
 
 INCLUDE_PATH = '_includes'
 
 module.exports = exports = (config, callback) ->
-  log.info
+  log.info "generate", "Begin generation"
   # First-run initialization
   postMask = ///^(\d{4})-(\d{2})-(\d{2})-(.+)\.(#{config.markdown_ext.join '|'}|html)$///
   time.tzset config.timezone


    log.verbose "generate", "Normalized includes: %s", Object.keys(normalized).join ', '
    callback null, normalized

resolveIncludes = (config, includes, converters) ->
  includeDir = path.join config.source, INCLUDE_PATH
  resolved = {}

  # Calculate dependency graph
  dependencyGraph = []
  for file, content of includes
    matches = content.match /\{%\s*include\s+([^\s%]+)\s*%\}/img
    if matches
      for str in matches
        match = str.match /\{%\s*include\s+([^\s%]+)\s*%\}/im
        # Ignore self-dependencies
        unless match[1] is file
          dependencyGraph.push [file, match[1]]
    else
      # Can resolve directly
      resolved[file] = tinyliquid.parse(content).code

  # Topological sort for processing includes since tinyliquid needs includes
  # to be precompiled
  # Note, can contain dupes
  try
    sorted = toposort(dependencyGraph).reverse()
  catch err
    log.verbose "generate", "Depdency graph for includes: %j", dependencyGraph
    throw new Error "Cyclic depdendency within includes"

  for file in sorted
    # Ignore files that are done, or don't exist
    continue if (file of resolved)
    continue unless file of includes

    # TinyLiquid requires parsed (not compiled) code in order for includes
    # to work properly
    parsedInclude = tinyliquid.parse includes[file], files: resolved
    resolved[file] = parsedInclude.code

  resolved

loadLayouts = (config, callback) ->
  log.verbose "generate", "Loooking for layouts in %s", config.layouts

      if err then return callback err

      # Now write all content to disk
      bundle = { site, config, liquidOptions, compiledLayouts, mergedPlugins, context }
      async.series([
        (cb) -> writePostsAndPages bundle, cb
        (cb) -> writeFiles bundle, cb
