I misread the code and thought the code kept looping until the mob spawn cap was hit. Upon furthur review, this is not true, so this patch doesn't do anything sane.
Change implementation, smaller diff, less NPE