Started refactoring of archetypes templates

What do you think? I didn't test it yet, just want to structure the code a bit.