Refactor function segments

Hopefully the last major configuration format change before release.

Fixes #1031