move compilation code to tower/template