Fixed a bug that could have caused a NPE.