Refactor javascript variables.
Encapsulate functions.