Make models a dict, and move Resource constructor complexity to a factory.