refactoring related to types; also allow field list in groups

interdependent with https://github.com/dimagi/commcare-hq/pull/960