Fixed all code analysis warnings

And made all ReSharper suggestsions too