Refactored roles and record types into lib