Revert "Revert "various fixes for sonar issues""

This reverts commit 687dbeb92870b0003afb5c2eb7573cf42a730263.
Revert "Revert "NPE checks""

This reverts commit e1cbe2d11a2b8872ea7043687c8a1095ec22d5ba.
Merge remote-tracking branch 'origin/master' into features/sonar-cleanup
Merge remote-tracking branch 'origin/master' into features/sonar-cleanup
Merge remote-tracking branch 'origin/features/sonar-cleanup'