Scrutinizer fixes

This can probably be merged safely in 3.1.0/master. 3.0 and 2.4 are likely to need their own cleanup.

As 2.4 will now require a full cleanup, I'm not sure if it's worth the effort.