fixed some potential NullPointerExceptions