Prevent NPEs and RuntimeExceptions