Fixes warnings, bad code and code style
Merge pull request #824 from alignan/fix_warnings

Warning fixes