Fixed null pointer exceptions introduced by code modifications