Fix circular dependencies around custom model