optimize templates and php code.