Fixed analyzer warnings and code cleanup