Fixed some NULL pointer exceptions
Merge commit '4b998e8bf9cf75a564816ba5b115552b066fc389'