Removed more warnings
Got rid of more warnings and fixed problems spotted in code analysis