Refined templates and conslidated js code.