   new Promise (resolve, reject) ->
 
     get_or_create_phantom().then (ph) ->
-      console.log ph
+
       ph.createPage().then (page) ->
 
         page.open(url)
           .then (status) ->
-            console.log status
             # Check loaded page has header section.
             # If not, wait more 1000 msec.
             new Promise (resolve, reject) ->

  else
    0

phantom_instances = []
###
List of PhantomJS instances.

Basically one instance will be reused. But when get_or_create_phantom method
called many times at the same time, multiple instances could be created.
To exit all instances safe, this list holds them.
###

get_or_create_phantom = ->
  ###
  Get an instance of PhantomJS.

  If there are no instances, this function creates it.
  ###
  if phantom_instances.length isnt 0
    new Promise (resolve) ->
      resolve phantom_instances[0]
  else
    phantom.create().then (instance) ->
      phantom_instances.push instance
      return instance


delete_phantom = ->
  ###
  Delete PhantomJS instances.

  It is safe to call this method many times.
  ###
  console.log phantom_instances.length
  while phantom_instances.length isnt 0
    phantom_instances.pop().exit()
  return null


# Register delete_phantom method so that it will be called when

                  reject reason

          .then (status) ->
            page.evaluate ->
              load_hidden_pages = (delay, callback) ->
                # Load hidden pages.
                #
