Public pensions, family allowances and endogenous demographic change