Code review: forms/groups/attributes APIs

A bunch of changes made before christmas - could do with a code review.
Not quite ready for a merge yet.