Fix element order and JSLint problems.

I don't know if my solution on the element order is correct but it works as a fix to my current project I'm working.