Clean up JS, add comments, refactor HTML into directives