         $scope.panelStack[0].item = $scope.csWizardOptions['form-item']
 
     $scope.$watchCollection 'panelStack', (newPanelStack, oldPanelStack) ->
+
       if newPanelStack
         attrs.$set 'numberOfPanels', newPanelStack.length
         $scope.numberOfPanels = newPanelStack.length
+      else
+        $scope.log("NotPanelStack")
 
     # ===== LIFECYCLE EVENTS ==============================
 

          directive = override.directive

      $scope.setOptions(resource, item, formMode, wizardMaxDepth, parent, directive)

    else

      $scope.log("singlePage branch")
      $scope.csWizardOptions = {}
      # TODO Check if all the parameters arrived
      # { resourceType, id, pageType}
      resource_type = $scope.resourceType
      formMode = $scope.pageType 
      if formMode != 'show' && formMode != 'edit'
        $scope.finish("'" + formMode + "' is not a valid page type!")
      $scope.csWizardOptions['form-mode'] = formMode
      wizardMaxDepth = 5
      csDescriptorService.getPromises()
      .then(()->
        return ResourceService.get($scope.resourceType)
      ).catch((error) ->
        errorMsg = "\"" + $scope.resourceType + "\" is not a registered resource"
        $scope.finish(errorMsg)
      ).then((_resource_) ->
          resource = angular.copy(_resource_)
          # Getting the resourc data
          resource.$get($scope.itemId, {include: '*'})
      ).catch((reason) ->
          # TODO process the reason
          errorMsg = "There is no " + resource.descriptor.name + " with the id: " + $scope.itemId
          $scope.finish(errorMsg)
      ).then((_item_)->
          item = _item_
      ).then( ()->
        #Setting events
        wizardCanceled = (() ->
          csRoute.go("index", {resourceType : resource.descriptor.type})
        ).bind(resource)

        wizardSubmitted =  (()->
          switch(formMode)
            when "create" then csAlertService.success('new_resource_created')
            when "edit" then csAlertService.success("changes_saved")
          csRoute.go("index", {resourceType : resource.descriptor.type})
        ).bind(formMode, resource)

        $scope.csWizardOptions.events = {
          'wizard-canceled' : wizardCanceled
          'wizard-submitted' : wizardSubmitted
        }
        $scope.setOptions(resource, item, formMode, wizardMaxDepth)
    )

    if $scope.panelNumberCallback


  link = ($scope, element, attrs, controller) ->

    ValidationError = () ->
    ValidationError.prototype = Error.prototype;

    #Setting csLog
    csLog.set($scope, "csWizard")

    $scope.loading = true
    $scope.errors = []

    $scope.setOptions = (resource, item, formMode, wizardMaxDepth, parent) ->

      $scope.log("setOptions")
      panelDescriptor = {
        resource : resource
        item : item
