Fix some issues pinpointed by Code Analysis