Fixed null reference / array out of bounds error.