Null pointer exceptions fix
Refactoring
Exceptions fix