Fixed null reference exceptions.