[Core] Fix some static code analysis warnings and improve performance (c2554)