 
   KodingError        = require '../error'
 
-  {secure, ObjectId, signature, daisy} = require 'bongo'
-  {Relationship}     = jraphical
-  {permit}           = require './group/permissionset'
+  { secure, ObjectId, signature, daisy } = require 'bongo'
+  { Relationship }   = jraphical
+  { permit }         = require './group/permissionset'
   Validators         = require './group/validators'
 
   @trait __dirname, '../traits/protected'

      if not @baseStackId
        return callback null, stackRevisionErrors.NOTFROMTEMPLATE

      JStackTemplate = require "./computeproviders/stacktemplate"
      JStackTemplate.one { _id: @baseStackId }, (err, template) =>
        return callback err  if err
        return callback new KodingError "Template not valid"  unless template

        status =
          if not template?.template?.sum or not @stackRevision

      { permission: 'delete own stack', validateWith: Validators.own }
    ]

    success: (client, callback) ->

      # TODO Implement delete methods.
      @update { $set: { status: 'Terminating' } }

      JProposedDomain  = require './domain'
      JMachine = require './computeproviders/machine'

      { delegate } = client.connection

      @domains?.forEach (_id) ->
        JProposedDomain.one { _id }, (err, domain) ->
          if not err? and domain?
            domain.remove (err) ->
              if err then console.error \
                "Failed to remove domain: #{domain.domain}", err

      @machines?.forEach (_id) ->
        JMachine.one { _id }, (err, machine) ->
          if not err? and machine?
            machine.remove (err) ->
              if err then console.error \
                "Failed to remove machine: #{machine.title}", err

      Relationship.remove {
        targetName : 'JStackTemplate'
        targetId   : @baseStackId
        sourceId   : delegate.getId()
        sourceName : 'JAccount'
        as         : 'user'
      }, (err) =>

        @remove callback

