remove unused elements from template