fix null references issues in commit 6b9f96697bb53f38ad01a11dee7ae9ef05924e72 @aaroncampf