 
       # This is a fallback mechanism and valid only for production. ~ GG
       if group.slug is 'koding'
-        {ObjectId} = require 'bongo'
-        group.stackTemplates = [ObjectId "53fe557af052f8e9435a04fa"]
-        console.error "[critical] Koding group template is not set!"
+        { ObjectId } = require 'bongo'
+        group.stackTemplates = [ObjectId '53fe557af052f8e9435a04fa']
+        console.error '[critical] Koding group template is not set!'
       else
-        return callback new KodingError "Template not set", "NotFound"
+        return callback new KodingError 'Template not set', 'NotFound'
 
     # TODO Make this works with multiple stacks ~ gg
     stackTemplateId = group.stackTemplates[0]
 
     # TODO make all these in seperate functions
-    JStackTemplate = require "./stacktemplate"
-    JStackTemplate.one { _id: stackTemplateId }, (err, template)->
+    JStackTemplate = require './stacktemplate'
+    JStackTemplate.one { _id: stackTemplateId }, (err, template) ->
 
       if err
         console.warn "Failed to fetch stack template for #{group.slug} group"
         console.warn "Failed to create stack for #{user.username} !!"
-        return callback new KodingError "Template not set", "NotFound", err
+        return callback new KodingError 'Template not set', 'NotFound', err
 
       if not template?
         console.warn "Stack template is not exists for #{group.slug} group"
         console.warn "Failed to create stack for #{user.username} !!"
-        return callback new KodingError "Template not found", "NotFound", err
-
-      checkTemplateUsage template, account, (err)->
+        return callback new KodingError 'Template not found', 'NotFound', err
+
+      checkTemplateUsage template, account, (err) ->
         return callback err  if err?
 
         res.template = template
         callback null, res
 
 
-guessNextLabel = (options, callback)->
-
-  {user, group, provider, label} = options
+guessNextLabel = (options, callback) ->
+
+  { user, group, provider, label } = options
 
   return callback null, label  if label?
 


checkTemplateUsage = (template, account, callback) ->

  {Relationship} = require 'jraphical'
  Relationship.count
    targetId   : template.getId()
    targetName : "JStackTemplate"
    sourceId   : account.getId()
  , (err, count) ->

    if err or count > 0
    then callback new KodingError "Template in use", "InUse", err
    else callback null


fetchGroupStackTemplate = (client, callback) ->

  reviveClient client, (err, res)->

    return callback err  if err


      if shouldPassCredential and not credential?
        unless provider in ['koding', 'managed']
          return callback new KodingError \
            'Credential is required.', 'MissingCredential'

      reviveCredential client, credential, (err, cred) =>

        if err then return callback err

        if shouldPassCredential and not cred?
          unless provider in ['koding', 'managed']
            return callback \
              new KodingError 'Credential failed.', 'AccessDenied'
        else
          options.credential = cred.identifier  if cred?.identifier

        reviveProvisioners client, provisioners, (err, provisioners) =>

          options.provisioners = provisioners  if provisioners?

