Refactored entity groups slightly and amended some comments.