Fixed null reference problems.