Added grouping to database models. This fixes #6.