Fix crate collection issues

Fixes #5953, #6427, and does some code style cleanups.
If we do this TODO hostile and friendly should be options IMO.