Fixed some potential NPEs, closing #2