fix some nil class bugs