Fixed a bug that was causing an NPE.
Fixed another bug that was causing an NPE.