Fixed a bug that was causing NPE's.