Fixes a bug where that could have lead to a null reference exception.