template integration, code cleaning