Migrate functions minus tests across