Fixing null and undefined bugs.