Adding custom functions and improving templating logic.