dev: handle required templates, put everything to separate files