Refactored templates and client side js