More debug prints and avoid null pointer.