Improved test coverage
Resolved some CA warnings
Prevented possible null reference exception