Code fixes

Tested all the ReSharper code issues that were resolved. Had to make
some code fixes.