Added some NPE protection.