#177 Added more null checks.