Ported back recent changes.