Massive (semi-automated) cleanup patch.
Sonar fixes.