Fix of static code analysis warnings and smaller refactoring