Code now handles gamma and beta templates.