Introduced helper functions 'spawn' and 'max_domain_id' for domain management.