Fix template build and compilation