This seems to duplicate functionality from #582.