Cleanup and modularize templates.