Fixed NULL pointer problems.