Code contract fixes for last commit
Fixed null reference exception