Fixed Karl's lack of null checks.

Signed-off-by: Ken 'Minalien' Murray <minalien@gmail.com>