Replaced most template javascript