Removed possible null pointer exceptions
Merged with master