Fixing a couple null pointer exceptions