Fixing fields and fieldgroup relations and writing tests.