General generation framework