Fixed a bunch of NPEs so that it runs