Extracted from #6
Extracted from #6