-{bindings, bind, duplex,
+{bind,
 section, h1, header, form, text, checkbox, div, ul, li, p, a, label, button, footer, strong, span
-list, each,
-flow
-txt
+each, txt
 extend} = dc
 
+################################################
 # store
-fetch = -> JSON.parse(localStorage.getItem('dc') || '[]')
-save = (todos) -> localStorage.setItem('dc', JSON.stringify(todos))
 
+fetch = -> JSON.parse localStorage.getItem('dc') || '[]'
+save = (todos) -> localStorage.setItem 'dc', JSON.stringify(todos)
+
+#######################################################################################################################
 # model
 # [ { title: string, completed: boolean } ... ]
 todos = []
 
+#######################################################################################################################
 # controller
+
 viewStatusHash = null
 editingTodo = null
 originalTodo = null

saving = false

getTodos = ->
  if viewStatusHash=='active' then todos.filter((todo) -> todo and !todo.completed)
  else if viewStatusHash=='completed' then todos.filter((todo) -> todo and todo.completed)
  else todos

remainingCount = -> todos.filter((todo) -> !todo.completed).length


toggleCompleted = (todo) ->
  todo.completed = !todo.completed
  save todos
  view.update()

markAll = ->
  if allChecked() then completed = false
  else completed = true

  valid = true
  for todo in todos
    if todo.completed!=completed
      todo.completed = completed
      valid = false

  if !valid
    save(todos)
    view.update()

editTodo = (todo) ->
  editingTodo = todo
  originalTodo = extend {}, todo
  view.update()

removeTodo = (todo) ->
  index = todos.indexOf todo
  todos.splice index, 1
  save todos
  view.update()

revertEdits = (todo) ->
