Removing more unneeded variables.
More cleanup
Moving javascript from actual template into controller.