Fixed two potential NullPointerExceptions