Adding C api for groupwise function alignment; several bugfixes