Added debugging printouts and null assertion.