template: split up code in smaller modules