Fixed various sonar issues. Fixed potential bug in CopyEngine.compareHead