Warning and error fixes

Created a new branch with fixes for clean PR.