Simplify code
Simplify code + fix code analysis warnings