Resolve many warnings and some code cleanup
Merge pull request #2346 from davidegrohmann/resolve-warning

Resolve many warnings and some code cleanup