Reorganizing code into separate template/js files