Removed possible null pointer exceptions