Refactored JS page, template and variable models