fixed the bugs brought up to me today, as well as the NPEs