Rough conversion of everything to new generic function reg. Now to
clean things up.